微信小程序:清空或修改 input 值

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yilovexing/article/details/81588208

微信小程序中的 input 组件是没有清除功能的,所以想要实现这个功能就得想其他的方法

我使用了一种特别讨巧的方法,就是当你需要清空或者替换的时候,其实是替换 input 的 value 值

这时候使用 this 对象先捕获现在 value 的值,然后再将其的值替换即可

wxml 代码

<!-- 导入 wxSearch 搜索组件-->
<import src="../../utils/wxSearch/wxSearch.wxml"/>
<template is="wxSearch" data="{{wxSearchData}}"/>

<!-- 搜索功能 -->
<view class="wxSearch-section">
  <view class="wxSearch-pancel">
    <input bindinput="wxSearchInput" bindfocus="wxSerchFocus" value="{{wxSearchData.value}}" class="wxSearch-input" placeholder=" 

猜你喜欢

转载自blog.csdn.net/yilovexing/article/details/81588208
今日推荐