为了账号安全,请及时绑定邮箱和手机立即绑定

在vue中,boolean类型的值怎么传给组件

在vue中,boolean类型的值怎么传给组件

目訫 2019-03-19 18:35:50
<!DOCTYPE html> <html lang="en"> <head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>Vue_component_oli</title>    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>    <style>        * {            margin: 0;            padding: 0;        }        ul {            list-style: none;        }        .list_cards ul {            display: flex;            flex-direction: row;        }        .box {            width: 300px;            height: 450px;            border: 5px solid #ccc;            border-radius: 10px;            margin-left: 10px;            overflow: hidden;        }        .colors {            opacity: 0.5;        }        .box_div_box {            width: 100%;            height: 70%;            background-color: aqua;            text-align: center;            line-height: 315px;        }        .box_btn_box input {            width: 30%;            height: 50px;            margin: 40px 10% ;        }    </style> </head> <body>    <div id="list_cards" class="list_cards">        <ul>            <list-card v-for="post in posts" :id="post.id" :title="post.title" :class="{colors: post.color}"></list-card>        </ul>    </div>    <script>        Vue.component('list-card', {            props: [ 'id','title', 'color' ],            template: '<li class="box"><div class="box_div_box"><!--img src="" /-->{{ title }}</div><div class="box_btn_box"><input type="button" value="详情" :disabled="color" /><input type="button" value="购买" :disabled="color" /></div></li>',        });        let vm = new Vue({            el: '#list_cards',            data: {                posts: [                    { id: '1', title: 'card-1', color: true, },                    { id: '2', title: 'card-2', color: false, },                    { id: '3', title: 'card-3', color: true, },                ],            },        });    </script> </body> </html>为什么disabled没有被赋上color的值?希望老师可以帮忙解答一下。
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 10215 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信