<template>
<section>
<div class="list">调用方法:{{ getName() }}</div>
<div class="list">script内调用方法:{{ getNameByMethods1() }}</div>
</section>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
@Component
export default class MethodComponent extends Vue {
// 原写法
// methods: {
// getName(){
// return 'Typescript'
// },
// getNameByMethods(){
// return this.getName()
// }
// }
// 现写法
getName() {
return 'Typescript';
}
getNameByMethods1() {
return this.getName();
}
}
</script>
<style lang="stylus"></style>
vue2+ts中methods的用法
最新推荐文章于 2024-05-23 20:06:07 发布