html JS Bin [Vue.JS组件容器的自定义标签] //来源https://jsbin.com/gifesom

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html JS Bin [Vue.JS组件容器的自定义标签] //来源https://jsbin.com/gifesom相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[Custom tag for Vue.JS component container]">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div id="myApp">
  <h1 is="my-component" title="Привет, Vue.JS!"></h1>
</div>


</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
  <script>
  window.app = new Vue({
    el: "#myApp",
    components: [
      Vue.component('my-component', {
        render: function(creatElement) {
          return creatElement(this.$vnode.data.tag, this.title);
        },
        props: {
          title: {
            type: String,
            default: 'Empty title',
          },
        },
      }),
    ],
  });

  </script>
</html>

以上是关于html JS Bin [Vue.JS组件容器的自定义标签] //来源https://jsbin.com/gifesom的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Vue.js 中保留自定义组件标签名称

在 Vue.js 中嵌套组件时出现未知的自定义元素

Vue JS - vue 组件上的自定义属性会导致 TS 错误

Laravel 5.6.7 和 Vue.js 中的自定义错误消息,尤其是组件

Vue js将HTML按钮名称属性作为PROPS传递

Vue.js Vuetify.js - 未知的自定义元素:<v-list-item>, <v-list-item-title> 您是不是正确注册了组件?