我准备给Object写个扩展函数,用来做一些我要用到的常规操作,于是写了
Object.prototype.test = function () {
return "test OK";
}
一编译就报错,说我的一个自定义组件报错。(没写这个之前一切正常)
这个组件很简单,代码如下
Component({
properties: {
title: String,
icon: String,
placeholder: String,
value: String,
max: {
type: Number,
value: -1
},
disabled: {
type: Boolean,
type: false
},
height: {
type: String,
value: "135rpx"
},
type: {
type: String,
value: "text"
},
TiHuan: {
type: Boolean,
value: true
}
},
methods: {
inputing: function (obj) {
let v = this.properties.TiHuan ? obj.detail.value.replace(/[<>"&\/`'?#*\"\\" ]/g, '') : obj.detail.value;
this.triggerEvent("change", v)
if (this.properties.TiHuan) return v;
}
}
})
报错说
'name' undfined.