JavaScript/vue.js/标签属性:修订间差异
来自康健生活
< JavaScript | vue.js
| (未显示同一用户的2个中间版本) | |||
| 第8行: | 第8行: | ||
<input v-if="show" type="file" capture="camera" /> | <input v-if="show" type="file" capture="camera" /> | ||
<input v-else type="file" multiple /></syntaxhighlight> | <input v-else type="file" multiple /></syntaxhighlight> | ||
<syntaxhighlight lang="html5"> | |||
:style="{background: 'url(' + | |||
( | |||
(item.voteStatus === -1) | |||
?require('@@/assets/img/search/u23_mouseOver.svg') | |||
:require('@@/assets/img/search/u23.svg') | |||
)+ ') no-repeat', | |||
cursor: ( | |||
(item.voteStatus === '-1') | |||
?'default' | |||
:'pointer' | |||
) | |||
}"</syntaxhighlight> | |||
== style == | |||
== class == | |||
vue 动态添加 class 的方法 | |||
<syntaxhighlight lang="html5"> | |||
<li v-for="(item,index) in items" :class="{'active':item.checked}" @click="isActive(item)">{{item.text}}</li> | |||
<script> | |||
methods: { | |||
isActive: function(item) { | |||
if (typeof item.checked == 'undefined') { | |||
//全局创建 | |||
//Vue.set(item,'checked',true); | |||
//局部创建 | |||
this.$set(item, 'checked', true); | |||
// console.log(item.text) | |||
} else { | |||
item.checked = !item.checked; | |||
} | |||
} | |||
} | |||
} | |||
</script> | |||
<script> | |||
methods: { | |||
isActive: function(item) { | |||
this.$set(item, 'checked', !item.checked); | |||
} | |||
} | |||
} | |||
</script> | |||
</syntaxhighlight> | |||
{{Unknown}} | |||
2020年7月22日 (三) 03:02的最新版本
标题文字
element.setAttribute(name,value)
element.removeAttribute(attrName)
event.target.getAttribute('businessType')
<input v-if="show" type="file" capture="camera" />
<input v-else type="file" multiple />
:style="{background: 'url(' +
(
(item.voteStatus === -1)
?require('@@/assets/img/search/u23_mouseOver.svg')
:require('@@/assets/img/search/u23.svg')
)+ ') no-repeat',
cursor: (
(item.voteStatus === '-1')
?'default'
:'pointer'
)
}"
style
class
vue 动态添加 class 的方法
<li v-for="(item,index) in items" :class="{'active':item.checked}" @click="isActive(item)">{{item.text}}</li>
<script>
methods: {
isActive: function(item) {
if (typeof item.checked == 'undefined') {
//全局创建
//Vue.set(item,'checked',true);
//局部创建
this.$set(item, 'checked', true);
// console.log(item.text)
} else {
item.checked = !item.checked;
}
}
}
}
</script>
<script>
methods: {
isActive: function(item) {
this.$set(item, 'checked', !item.checked);
}
}
}
</script>
(来源摘自互联网示例,作者 未知)
No categories