<!-- 包含该 prop 没有值的情况在内,都意味着 `true`。-->
<blog-post is-published></blog-post>
<!-- 即便 `false` 是静态的,我们仍然需要 `v-bind` 来告诉 Vue -->
<!-- 这是一个 JavaScript 表达式而不是一个字符串。-->
<blog-post v-bind:is-published="false"></blog-post>
```html
<!DOCTYPE html>
<html lang="zh">
<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>传入一个布尔值</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="hzh">
<hzh-component v-bind:is-published="false"></hzh-component>
</div>
<script>
Vue.component('hzh-component', {
props: ['is-published'],
template: '<h3>是否已经出版:{{isPublished}}</>'
})
new Vue({
el: '#hzh',
})
</script>
</body>
<!-- 用一个变量进行动态赋值。-->
<blog-post v-bind:is-published="post.isPublished"></blog-post>
<!DOCTYPE html>
<html lang="zh">
<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>传入一个布尔值</title>
<script src="./vue.js"></script>
</head>
<body>
<div id="hzh">
<hzh-component v-for="post in posts" v-bind:post="post" v-bind:key="post.key"></hzh-component>
</div>
<script>
Vue.component('hzh-component', {
props: ['post'],
template: '<h3>是否已经出版:{{post.isPublished}}</h3>'
})
new Vue({
el: '#hzh',
data: {
posts: [
{id: 1, isPublished: false}
]
}
})
</script>
</body>