示例代码如下所示:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vue模版语法学习</title>
<script type="text/javascript" src="../Js/vue.js"></script>
</head>
<body>
<div id="root">
<h1>插值语法</h1>
<h1>插值语法,用于标签体内</h1>
<h1>hello {{name}}</h1>
<h1>Vue {{nickname}}</h1>
<hr />
<h1>Vue指令语法,用于标签属性</h1>
<h1>注:v-bind:可简写为:</h1>
<a v-bind:href="url">百度一下</a>
<a :href="url">百度一下</a>
<hr />
<a v-bind:href="url.toUpperCase()">百度一下</a>
<!-- <a :href="url.toLowCase()">百度一下</a> -->
<h1>获取当前时间戳: {{Date.now()}}</h1>
<hr />
<h1> {{mydata.oneAtt}}</h1>
<h1> {{mydata.towAtt}}</h1>
<hr />
<h1>hello {{name.toUpperCase()}}</h1>
<h1>转大写:{{textlowupper.toUpperCase()}}</h1>
<h1>转小写:{{textlowupper.toLowerCase()}}</h1>
</div>
</body>
</html>
<script type="text/javascript">
Vue.config.productionTip = false
const one = new Vue({
// 方式一:通过id选择器获取对象,也可理解为获取容器
el: '#root',
data: {
name: 'vue',
nickname: 'vue.js',
url: 'https://www.baidu.com/',
textlowupper: 'AbcdEfg',
// data 对象中可嵌套多层对象哦
mydata:
{
oneAtt: '我是一个嵌套对象的属性哦',
towAtt: '我是嵌套对象的第二个属性哦'
}
},
})
</script>
运行效果:

总结:

博客内容主要用于日常学习记录,内容比较随意,如有问题,还需谅解!!!

浙公网安备 33010602011771号