zoukankan      html  css  js  c++  java
  • Vue::is特性用法

     看完之后能感觉到就是想要把blog-post-row的内容放在table中的tr标签中,是通过:is特性来进行使用的。但是感觉不知道具体怎么用,那就下面的这个示例再直观的感受一下:


    <template>
    <div class="hello">
    <h1>{{ msg }}</h1>
    <h2>Essential Links</h2>

    <div id="app1">
    <el-table :data="tableData">
    <el-table-column is="blog_post_row"></el-table-column>
    </el-table>
    </div>

    </div>
    </template>

    <script>
    export default {
    name: 'HelloWorld',
    data () {
    return {
    tableData: [{
    date: '2016-05-02',
    name: '王小虎',
    address: '上海市普陀区金沙江路 1518 弄'
    }, {
    date: '2016-05-04',
    name: '王小虎',
    address: '上海市普陀区金沙江路 1517 弄'
    }, {
    date: '2016-05-01',
    name: '王小虎',
    address: '上海市普陀区金沙江路 1519 弄'
    }, {
    date: '2016-05-03',
    name: '王小虎',
    address: '上海市普陀区金沙江路 1516 弄'
    }],
    msg: 'Welcome to Your Vue.js App'
    }
    },
    methods: {},
    components: {
    blog_post_row: {
    template: `
    <div>
    <el-table-column prop="date" label="日期" width="180"></el-table-column>
    <el-table-column prop="name" label="姓名" width="180"></el-table-column>
    <el-table-column prop="address" label="地址" width="180"></el-table-column>
    </div>
    `
    }
    }
    }
    </script>

    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped>
    </style>
    ————————————————
    也可以看一下其他朋友的示例哈: 


    <template>
    <div class="hello">
    <h1>{{ msg }}</h1>
    <h2>Essential Links</h2>

    <div id="app1">
    <button @click="toshow">点击让子组件显示</button>
    <component :is="which_to_show"></component>
    </div>

    </div>
    </template>

    <script>
    import Vue from 'vue'
    /* eslint-disable no-new */

    export default {
    name: 'HelloWorld',
    data () {
    return {
    which_to_show: 'first',
    msg: 'Welcome to Your Vue.js App'
    }
    },
    methods: {
    toshow: function () {
    var arr = ['first', 'second', 'third', '']
    var index = arr.indexOf(this.which_to_show)
    if (index < 3) {
    this.which_to_show = arr[index + 1]
    } else {
    this.which_to_show = arr[0]
    }
    }
    },
    components: {
    first: {
    template: `<div>这里是子组件</div>`
    },
    second: {
    template: `<div>这里是子组件2</div>`
    },
    third: {
    template: `<div>这里是子组件3</div>`
    }
    }
    }
    </script>

    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped>
    </style>
    ————————————————

    看到我的div了吗?在你那你就完蛋了
  • 相关阅读:
    HDU 2089 不要62
    HDU 5038 Grade(分级)
    FZU 2105 Digits Count(位数计算)
    FZU 2218 Simple String Problem(简单字符串问题)
    FZU 2221 RunningMan(跑男)
    FZU 2216 The Longest Straight(最长直道)
    FZU 2212 Super Mobile Charger(超级充电宝)
    FZU 2219 StarCraft(星际争霸)
    FZU 2213 Common Tangents(公切线)
    FZU 2215 Simple Polynomial Problem(简单多项式问题)
  • 原文地址:https://www.cnblogs.com/web-shu/p/11970314.html
Copyright © 2011-2022 走看看