flufff
flufff
  • 发布:2019-10-17 14:17
  • 更新:2020-11-03 14:01
  • 阅读:2335

uniapp+ts+vue-property-decorator 注册组件无效

分类:uni-app

子组件

<template>  
  <view class="container">  
    <view class="content">678</view>  
    <view class="content">678</view>  
    <view class="content">678</view>  
    <view class="content">678</view>  
  </view>  
</template>  
<script lang="ts">  
import { Vue, Component, Prop } from "vue-property-decorator";  
@Component({  
  name: "LayoutFooter"  
})  
class LayoutFooter extends Vue {  
  //是否固定在底部  
  // @Prop(Boolean)  
  // fixed: boolean = true;  
  mounted(): void {  
    console.log("???");  
  }  
}  
export default LayoutFooter;  
</script>

父组件

<template>  
  <view class="content">  
    <image class="logo" src="/static/logo.png" />  
    <LayoutFooter  />  
    <view class="text-area">  
      <text class="title">- {{title}} -</text>  
    </view>  
  </view>  
</template>  
<script lang="ts">  
import { Vue, Component } from "vue-property-decorator";  
import LayoutFooter from "components/LayoutFooter";  
console.log(Vue,Component, LayoutFooter);  
@Component({  
  name: "HomePage",  
  components: {  
    LayoutFooter  
  }  
})  
class HomePage extends Vue {  
  title = "Hello";  

  onLoad() {  
    console.log(this);  
    // login().then(res => {  
    //   console.log(res);  
    // });  
  }  
}  
export default HomePage;  
</script>

页面不显示子组件 打印引入是有值的 打印父组件实例$children: [],是空数组,小程序,app 都不行,只有 h5 是好的

2019-10-17 14:17 负责人:无 分享
已邀请:
珠海思格特

珠海思格特

这个问题我也遇到了

h***@gmail.com

h***@gmail.com

这个问题现在还是这样。
楼主现在解决这个问题了么

  • flufff (作者)

    所有属性都断言非空就行了,比如 { value!: '100' }

    2020-12-10 21:02

该问题目前已经被锁定, 无法添加新回复