【问题标题】:How to make a Base component that will allow other components to inherit new functionality or code from it in Vue JS如何在 Vue JS 中制作一个允许其他组件继承新功能或代码的 Base 组件
【发布时间】:2021-11-14 21:05:40
【问题描述】:

组件 1:-

<template>
<blur :isData="isData">
 
    <!-- logic/implementation of component 1 -->
    <div>
    
    </div>


</blur>
<template>

<script>

import blur from "../shared/Blur";

 name: "component-1",
  components: {
    blur,
  },

</script>

就像这个component1.vue,我有多个使用blur 组件的组件。是否有可能不是在每个组件中编写和导入blur,而是可以创建一些基类,可以在文件夹中的每个组件中传输模糊功能。在vue中可以实现这样的事情吗?

【问题讨论】:

    标签: vue.js inheritance vuejs2 vue-component vuetify.js


    【解决方案1】:

    使用Vue.component,您可以创建全局注册的组件:

    Vue.component('my-component-name', {
      // ... options ...
    })
    

    了解更多here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-30
      • 2018-11-12
      • 2019-04-11
      • 2014-01-10
      • 2021-07-24
      • 2018-03-05
      • 1970-01-01
      相关资源
      最近更新 更多