You won't be able to access data properties like this.msg
until the data
method has returned.
Just set that value outside of the return
statement:
data () {
let msg = '';
return {
msg: msg,
rgbValue: '',
newColor: {
color: msg
}
}
}
If you need the newColor
property to always reflect the value of this.msg
, you could make it a computed property instead:
data () {
return {
msg: '',
rgbValue: '',
}
},
computed: {
newColor() {
return { color: this.msg }
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…