感谢大神,解决了,那那个 this.search(),ide报错怎么解决呢。
自定义组件怎么自己调用初始化方法?// components/appointment/appointment.js Component({ /** * 组件的属性列表 [代码]// components/appointment/appointment.js[代码][代码]Component({[代码][代码] [代码][代码]/**[代码][代码] [代码][代码]* 组件的属性列表[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]properties: {[代码] [代码] [代码][代码]},[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 组件的初始数据[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]listData: [][代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 组件的方法列表[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]methods: {[代码][代码] [代码][代码]onLoad() {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]search() {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]listData: [[代码][代码] [代码][代码]{ [代码][代码]"project"[代码][代码]: [代码][代码]"项目A"[代码][代码], [代码][代码]"sStatus"[代码][代码]: [代码][代码]"可预约"[代码][代码], [代码][代码]"xStatus"[代码][代码]: [代码][代码]"已满"[代码] [代码]},[代码][代码] [代码][代码]{ [代码][代码]"project"[代码][代码]: [代码][代码]"项目B"[代码][代码], [代码][代码]"sStatus"[代码][代码]: [代码][代码]"已满"[代码][代码], [代码][代码]"xStatus"[代码][代码]: [代码][代码]"可预约"[代码] [代码]},[代码][代码] [代码][代码]{ [代码][代码]"project"[代码][代码]: [代码][代码]"项目C"[代码][代码], [代码][代码]"sStatus"[代码][代码]: [代码][代码]"已满"[代码][代码], [代码][代码]"xStatus"[代码][代码]: [代码][代码]"已满"[代码] [代码]},[代码][代码] [代码][代码]][代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]attached() {[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]lifetimes: {[代码][代码] [代码][代码]// 组件的生命周期函数,用于声明组件的生命周期[代码][代码] [代码][代码]attached: () => {[代码][代码] [代码][代码]console.log(1)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]ready: () => {[代码][代码] [代码][代码]console.log(2)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]moved: () => {[代码][代码] [代码][代码]console.log(3)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]detached: () => { [代码][代码] [代码][代码]console.log(4)[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]},[代码][代码] [代码][代码]pageLifetimes: {[代码][代码] [代码][代码]// 组件所在页面的生命周期函数[代码][代码] [代码][代码]show: () => {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]hide: () => { }[代码][代码] [代码][代码]},[代码] [代码]})[代码]这个search()方法怎么在初始化的时候调用?写this.search()老是提示错误 =========================================================================== 错误如下 [图片] [图片] [图片] 感谢各位大神,现在已经能正常显示 但是ide还是报错,这个是不是ide对ts不友好?还是我写法有问题? 我只要IDE有错,点击预览就会报执行自定义预览前预处理命令失败。 [图片] [图片] 下面的也是这个问题,在组件中添加方法,只要写了参数就会提示错误,但是代码运行正常 [图片] [图片]
2019-10-22