错误:
编译器报了
“num.indexOf is not a function; [Component] Event Handler Error @ pages/USgoodprice/USgoodprice#bound getTest
TypeError: num.indexOf is not a function”
很狗血 ,查了半天,

案例重现:
我首先先使用了一个简单版
.wxml
<view class="bg-g tr">
<view class="td">test</view>
<input class="td " placeholder='输入' bindinput='getNum'></input>
</view>
<view class="bg-g tr">
<view class="td">结果</view>
<view class="td">{
{test}}</view>
</view>
<button bindtap='getTest' type="primary">计算</button>
.js
const util = require('../../utils/util.js');
Page({
/**
* 页面的初始数据
*/
data: {
test:''
},
getTest :function(e){

本文详述了在WXML开发中遇到的num.indexOfisnotafunction错误的成因与解决办法,通过实例演示如何正确转换数字为字符串进行处理。

3万+

被折叠的 条评论
为什么被折叠?



