首页 > 代码库 > Vuejs学习笔记1
Vuejs学习笔记1
首次写vue可能会出现:[Vue warn]: Cannot find element: #app
这是因为你的js在html页面头部引入的原因,自定义js文件要最后引入,因为要先有元素id,vue才能获取相应的元素。
示例:
1.index.js
var app = new Vue({
el : ‘#app‘,
data: {
message: ‘Hello Vue.js!‘
}
})
2.index.html
<html>
<head>
<title>Vuejs</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script src="http://www.mamicode.com/vue.js"></script>
<script src="http://www.mamicode.com/index.js"></script>:这里自定js文件要在最后引入。
</body>
</html>
Vuejs学习笔记1
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。