报错
Property 'height' does not exist on type '{ cheight(): any; }'. Did you mean 'cheight'?
怎么才能不用 this as any 来使用
以下是整页代码
<template>
<view>
<view :dd="cheight" @click="dds">
测试1
</view>
</view>
</template>
<script lang="ts">
export default {
name:"ceshi1",
props:{
height: {
type: [Number, String],
default: 251
},
},
data() {
return {
};
},
computed:{
cheight(){
return this.height
}
},
methods:{
cheight(){
//报错
//Property 'height' does not exist on type '{ cheight(): any; }'. Did you mean 'cheight'?
return this.height
},
dds(){
//不报错
return (this as any).height
}
}
}
</script>
<style>
</style>
0 个回复