• 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了吗?在你那你就完蛋了
  • 相关阅读:
    链接唤醒IOSApp
    C#抽象属性
    c#结构体与类的区别
    广告学入门
    个性化推荐十大挑战[
    MapReduce 读取和操作HBase中的数据
    mysql sql命令大全
    从B 树、B+ 树、B* 树谈到R 树
    MapReduce操作HBase
    Meanshift,聚类算法
  • 原文地址:https://www.cnblogs.com/web-shu/p/11970314.html
Copyright © 2020-2023  润新知