vue这个为什么报错?

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
    .test{color: red}
    </style>
    <script src="vue.js"></script>
    <script type="text/javascript">
        window.onload=function(){
            let obj={
                message:'hahha'
            }
            new Vue({
                el:"#app",
                data:obj
            })
        }
    </script>
</head>
<body>
<div id="app">
    <span v-bind:class="test">{{message}}</span>
</div>
</body>
</html>

提示:

[Vue warn]: Property or method "test" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. 
阅读 2.9k
1 个回答

你的vue中未声明test变量或者未定义test函数

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题