<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-default/index.css">
</head>
<body>
    <div id="app">
        <component :is="name" @click.native="click"></component>
    </div>
    <!-- 先引入 Vue -->
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script>
        Vue.component('btn', {
            template: '<el-button>按钮</el-button>'
        })

        new Vue({
            el: '#app',
            data: function () {
                return { name: 'btn' }
            },
            methods: {
                click() {
                    console.log('click')
                }
            }
        })
    </script>
</body>
</html>

 @click.native

Logo

前往低代码交流专区

更多推荐