Component 里有个bindinput提示在parent index页面没有找到?

发布于 8 年前作者 yanxiulan8834 次浏览最后编辑 8 年前来自 ask

我在pages/index/index下面用了一个Component,而这个Component里面有个input并且设置bindinput=“searchInput”。在这个Component的js文件里,我已经定义了这个searchInput方法。模拟器没有问题,但是真机运行提示pages/index/index里面没有定义这个searchInput。关键是这个是在Component里的。难道每个在Component里bind了还要在它的parent页面又要bind一次?

/pages/index/index.wxml
 
<discover></discover>
 
/pages/discover/home/home.wxml
 
<input type="text" bindinput="searchInput"></input>
 
/pages/discover/home/home.js
 
methods: {
    searchInput(e) {
        this.setData({
            query: e.detail.value
        })
 
    },
}

3 回复
renmin
renmin1 楼6 年前

我不管3721,在pages/index/index加了这个searchInput提示消失了,但是bindtap点击居然没效果。哎

hanjie
hanjie2 楼6 年前

没代码片段 我猜不出来

luxia
luxia3 楼6 年前

代码片段