相关疑难解决方法(0)

如何将数据对象的值放在另一个数据对象vueJS中

这是我的代码:

data () {
  return {
    msg: '',
    rgbValue: '',
    newColor: {
      color: this.msg
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

此代码不起作用.我想把价值msg放在我的对象中newColor.有没有人有办法解决吗?

以下是代码的补充:

data () {
            let msg =  '';
            return {
                msg: msg,
                rgbValue: '',
                newColor: {
                    color: msg
                }
            }
        },
        components: {
            HeaderComponent: require('./HeaderComponent.vue')
        },
        methods: {
            msgFunc: function () {

                colorsRef.push(this.newColor);

                const app = document.querySelector('#app');
                const rgbValueContainer = document.querySelector('.rgb-value');

                if (this.msg[0] !== '#') {
                    this.msg = '#'
                }
                app.style.backgroundColor = this.msg


                function convert(hex) {
                    hex = …
Run Code Online (Sandbox Code Playgroud)

vue.js vuejs2

6
推荐指数
1
解决办法
6075
查看次数

标签 统计

vue.js ×1

vuejs2 ×1