Component({ mixins: [], data: { userName:'', }, props: { name:'未定义', imgUrl:'', width:'', height:'', fSize:'', }, //为渲染后回调,此时页面已经渲染,通常在这里请求服务端数据比较合适。 didMount() { this.setName(); }, //为更新后回调,每次组件数据变更的时候都会调用。 didUpdate() { }, //为删除后回调,每当组件示例从页面删除的时候会触发此回调。 didUnmount() { }, methods: { setName(){ var str=this.props.name; this.setData({ userName:str.substring(str.length-2) }) } }, });