LoginSignup
10
4

More than 1 year has passed since last update.

Vue.jsで「TypeError: undefined is not an object (evaluating 'l.$set')」エラー

Last updated at Posted at 2019-04-05

Vue.jsで以下のchange~~メソッドを呼び出したところ・・・

App.Vue
data: () => {
    return {
        connect: {
          'connectStatus': '切断中',
        }
    }
},
methods: {
    changeConnectStatus: (status) => {
      this.$set(this.connect, 'connectStatus', status);
    },
}

コンソールに以下のエラーが出た。

TypeError: undefined is not an object (evaluating 'l.$set')

()=>ではなくfunctionにしよう

以下のようにすることで解決した。

App.Vue
changeConnectStatus: function(status) {
   this.$set(this.connect, 'connectStatus', status);
},

10
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
4