首先需要在wxml文件的输入框内添加绑定bindinput:

!--index.wxml--view class="container"  input placeholder="请输入内容" bindinput='expInput'//view

然后在js文件中进行赋值操作:

//index.js//获取应用实例const app = getApp()Page({  data: {    text: ""  },//获取输入框的内容,并赋值到text中  expInput: function (e) {    this.setData({ text: e.detail.value })  },

这样就获取到了输入框中的内容。

TAG标签: 微信小程序微信小程序输入框

http://www.xiaochengxub.com/read-105600.html