.async的用法

100 阅读1分钟

父组件,也就是需要显示的页面today-bad

  • 这个title的内容不是固定的,给他绑定了一个titleName;
  • 因为titleName会持续的变化,所以放在computed里面
<swo-title-bar :title.async="titleName" :isBack="true"></swo-title-bar>
-------------------
computed: {		
  titleName() {
  if (this.queryData.pageLabel == '不良品') 
  return this.queryData.timeLabel + this.queryData.pageLabel
  return '今日不良'
			},

子组件的内容

  • 在子组件swo-title-bar,里面需要填入一个title;
  • 这个title是由父组件传过来的;
  • 在子组件里面用props来接收;
  • title的默认值default是空值;
<slot name="content">
<view>					
 <view>{{title}}</view>
</slot>
--------------
export default {
props: {
  title:{
  default:" "
 }
   }
     }