"v-bind: " 可简写的为 ": "
提取嵌套的值
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>模板语法</title>
<!-- 引入Vue -->
<script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<!-- 准备好一个容器 -->
<div id="root">
<h1>插值语法</h1>
<h3>你好,jack</h3>
<hr />
<h1>指令语法</h1>
<!-- v-bind:绑定 -->
<a v-bind:href="url" x="hello">百度1</a>
<a :href="url" :x="hello">百度2</a>
<a :href="school.url" :x="school.name">百度3</a>
</div>
</body>
<script type="text/javascript">
Vue.config.productionTip = false // 阻止 vue 在启动时生成生产提示
new Vue({
el:'#root',
data:{
name:'jack',
url:'https://www.baidu.com',
hello:'你好',
school:{
name:'Mee',
url:'https://www.baidu.com',
}
}
})
</script>
</html>