调试vue发现错误,提示方法没有定义,在IDE工具提示是要注意选择正确的选项:

代码:

 new Vue({
        el: '#blist',
        delimiter: ['[[', ']]'],
        data: {
            message: 'hi vueeee',
        },
        method: {
            getbooks: function () {
                console.log(123)
                var url = "http://127.0.0.1:8000/booklist/books_view"
                axios.get(url).then((response) => {
                    console.log(response)
                }).catch((error) => {
                    console.log(error)
                })
            }
        }
    })

异常如下:
[Vue warn]: Property or method “getbooks” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data

原因:关键词拼写错误,pycharmt提示不小心选错
应是:methods,delimiters

pycharm提示多个,注意选择正确的:
在这里插入图片描述

Logo

前往低代码交流专区

更多推荐