靜態傳值爲父組件向子組件傳遞常量數據,所以只能傳遞String字符串類型。小程序
<view> <child name="leinov"></child> </view>
<template lang="wxml"> <view> {{name}} </view> </template> <script> props={ name:String } onLoad(){ console.log(this.name);//leinov } </script>
parentsession
<script> export default class Parents extends wepy.page { data = { tabdata:{}, //下面要用這裏必需要寫上 } async onLoad() { let data = await getData(,"public/data",{session_key:"1234456"}); this.tabdata= data.tab; this.$apply();//必須 } } </script> <template lang="wxml"> <view class="title" slot="title"></view> <view class="title" slot="content"> <Tab :tab.sync="tabdata" ></Tab> </view> </template>
childapp
<template lang="wxml"> <view class="title" slot="title">{{tab}}</view> </template>
export default class Tab extends wepy.component { props = { tab:{ type:Object, default:null, twoWay:true } }
如下必須注意框架