vue.js用cdn引入

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>filmMobile</title>
</head>
<body>
	<div id="app">
		{{m}}  <br>
		<todo-item></todo-item>

	</div>
</body>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
	<script>
		// 定义名为 todo-item 的新组件
		Vue.component('todo-item', {

		  template: '<p>这是个待办项组件</p>'
		})


		var app= new Vue({
				el:"#app",
				data:{
					m:"hello vue.js",
				},		 
		});
	</script>
</html>

注意的坑:应该先注册组件,后创建实例。否则报错;

组件保持范围。居于实例容器里面

猜你喜欢

转载自blog.csdn.net/milli236/article/details/80511044