html页面使用组件

2024-01-11  本文已影响0人  輪徊傷

一、新建myTable.js文件

export default Vue.component('CommomTable', {
    template: `<div>xxx</div>`,
    props: {
        list: {
          type: Array,
          default: () => [],
        },
      },
      data() {
        return {
          dataItem: [],
        }
      },
      mounted() {
      },
      // 方法
      methods: {
       
      },
})

二、html页面中引入

<common-table :list="list"> </common-table>

<script type="module">
    import CommonTable from '/Public/commom/table.js?v={$Think.config.FILE_VERSION}';
    import http from '/Public/js/http.js';

    new Vue({
        el: '#app',
        components: {
            CommonTable
        },
        data() {
            return {
               list: [1,2,3]
            }
        },
        methods: {
            getList() {
                console.log(this.queryData, 'queryData');
                this.$refs.commonTableRef.reload()
            },
        }
    })
</script>
```;
上一篇 下一篇

猜你喜欢

热点阅读