JavaScript/vue.js/标签属性:修订间差异
来自康健生活
创建页面,内容为“== 标题文字 == <syntaxhighlight lang="javascript"> element.setAttribute(name,value) element.removeAttribute(attrName)</syntaxhighlight> <syntaxhighlight lang="h…” |
|||
| (未显示同一用户的3个中间版本) | |||
| 第2行: | 第2行: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
element.setAttribute(name,value) | element.setAttribute(name,value) | ||
element.removeAttribute(attrName)</syntaxhighlight> | element.removeAttribute(attrName) | ||
event.target.getAttribute('businessType')</syntaxhighlight> | |||
<syntaxhighlight lang="html5"> | <syntaxhighlight lang="html5"> | ||
<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}} | |||