大概是只仓鼠 2022-03-31 16:11 采纳率: 79.6%
浏览 17
已结题

为什么input标签上的这些searchAll事件都无法被触发,甚至search也没有被更改

<template>
<div id="main-search">
  <div class="main-search-header">
    <Icon type="ios-arrow-back" class="main-search-header-icon" @click="back"/>
    <Input search  enter-button ref="input"  class="main-search-header-input" :v-model="search" @click="searchAll" on-clear="searchAll" on-blur="searchAll" >
    </Input>
  </div>
    <CellGroup class="cell-group"  @on-click="changeSelectedPausedIndex">
      <Cell v-for="(item,index) in tablist" :key="index" class="cell-title" :class="{'cell-title-select':(selectIndex === index)}"  :name="index">
        <div >
          <h3>{{item.label}}</h3>
        </div>
      </Cell>
    </CellGroup>
    <div class="content" >
        <router-view :inputValue='search' />
    </div>
  </div>

</template>

<script>
export default {
  name: 'search',
  data: () => {
    return {
      theme1: 'light',
      showLogoutModal: false,
      search: null,
      badgeMax: 99,
      text: '实现指定url跳转,这个方法不会向history栈添加记录,使用后退this.$router.back();会返回到上上一个页面。因为它的上个页面是不存在的。history栈没有记录',
      selectIndex: 0,
      tablist: [{
        id: '0',
        label: '全部',
        url: 'search-all'
      },
      {
        id: '1',
        label: '应用',
        url: 'search-app'
      },
      {
        id: '2',
        label: '消息',
        url: 'search-msg'
      }
      ]
    }
  },
  methods: {
    searchAll (e) {
      window.alert('HANDEL')
      console.log(e)
    },
    changeSelectedPausedIndex (e) {
      console.log(this.search)
      const _this = this
      this.selectIndex = e
      const newPath = `/search/${this.tablist[e].url}`
      if (newPath !== this.$router.currentRoute.path) {
        this.$store.dispatch('saveCurrentStep', newPath)
        this.$router.replace({
          path: newPath,
          query: {
            'search-value': _this.search
          }
        })
      }
    },
    back () {
      window.history.back()
    },
    inputFocus (type) {
      this.$refs.input.focus({
        cursor: type
      })
    }
  },
  mounted () {
    this.inputFocus('end')
  }
}
</script>

<style>
</style>



  • 写回答

1条回答 默认 最新

  • iloveozz 2022-03-31 16:27
    关注

    确定是@click 不是@change

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 4月21日
  • 已采纳回答 4月13日
  • 修改了问题 3月31日
  • 修改了问题 3月31日
  • 展开全部

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效