computed で classを動的に指定
2729 ワード
html
index.html
<div id="app">
<p :class="textStyle">test text</p>
</div>
css
style.css
.textColor{
color: blue;
}
.textFont {
font-size: 30px;
background: red;
}
Vue.js
new Vue({
el: "#app",
data: function(){
return {
shouldApply: true
}
},
computed: {
textStyle: function() {
return {
textColor: this.shouldApply,
textFont: this.shouldApply
}
}
}
})
※computedはreturnとthisがいるよ
Author And Source
この問題について(computed で classを動的に指定), 我々は、より多くの情報をここで見つけました https://qiita.com/t_109609akg/items/8a4ec11c52ee604d64c2著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .