美文网首页
html页面使用组件

html页面使用组件

作者: 輪徊傷 | 来源:发表于2024-01-11 14:05 被阅读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>
```;

相关文章

网友评论

      本文标题:html页面使用组件

      本文链接:https://www.haomeiwen.com/subject/mvjgqdtx.html