Vue extends属性怎么使用

2023-05-18,

本文小编为大家详细介绍“Vue extends属性怎么使用”,内容详细,步骤清晰,细节处理妥当,希望这篇“Vue extends属性怎么使用”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

引言

App.vue

<template>
  <div>
    <Son></Son>
  </div>
</template>
<script>
import Son from "./components/Son";
export default {
  components: {
    Son,
  },
};
</script>
<style scoped></style>

Son.vue

<template>
</template>
<script>
import HelloWorld from "./HelloWorld.vue";
export default {
  extends: HelloWorld,
  data() {
    return {
      aa: 10,
    };
  },
};
</script>

HelloWorld.vue

<template>
  <div>
    <h2>{{ aa }}</h2>
    <h2>{{ bb }}</h2>
  </div>
</template>
<script>
export default {
  data() {
    return {
      aa: 0,
      bb: 123,
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.aa += 10;
    },
  },
};
</script>
<style scoped></style>

读到这里,这篇“Vue extends属性怎么使用”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注本站行业资讯频道。

《Vue extends属性怎么使用.doc》

下载本文的Word格式文档,以方便收藏与打印。