插值表达式和v-bind的使用
插值表达式
v-html 指令
v-once指令 -- 只渲染一次
插值表达式可以使用 js表达式,如三元运算符;但不能使用js语句,例如if
v-bind指令能设置html标签的属性值,例如设置h2的title
<h2 v-on:click="handleItemClick" v-html="message" v-once title="message"> </h2>
这跟使用组件时,通过v-bind指令,将属性值传入组件props是相似的
Demo9.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello World</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="app"