国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - 為什麼下面這段js程式碼會報, function not found的錯誤呢?
過去多啦不再A夢
過去多啦不再A夢 2017-06-30 09:53:26
0
3
741

vuex程式碼如下

export default {
    data () {
        return {
            content: ''
        };
    },
    methods: {
        onKeyup (e) {
            if (e.ctrlKey && e.keyCode === 13 && this.content.length) {
                this.sendMessage(this.content);
                this.content = '';
            }
        },
        sendMessage (content) {
            store.dispatch('sendMessage', content);
        }
    }
};

執(zhí)行到onKeyup 的時候, 提示Uncaught TypeError: this.sendMessage is not a function
, 是不是我哪裡寫錯了, 我還沒看出來。 。 ??闯鰜淼慕o指教一下哈, 多謝。

過去多啦不再A夢
過去多啦不再A夢

全部回覆(3)
女神的閨蜜愛上我

1樓正解
一般來說用vuex的寫法應(yīng)該是
sendMessage (content) {

this.$store.dispatch('sendMessage', content);

}

然後在actions裡註冊 sendMessage 這個方法。
記得不要忘了 mutations.js也要寫上

學(xué)霸

是否註冊了sendMessage這個action?

女神的閨蜜愛上我

直接sendMessage不就行了幹嘛要this.sendMessage?

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板