如何在js文件中使用typeof判断变量类型?
发布于 3 年前 作者 yong37 6677 次浏览 来自 官方Issues

detectType(){

        wx.cloud.database().collection(‘test’).get().then(res=>{

            res.data.forEach(element => {

                // 判断数据类型

                console.log(typeof element.price )

            });

        })

提示错误:

VM220:12 页面【pages/goods/list]错误:

 Error: module “@babel/runtime/helpers/typeof.js” is not defined

    at p (VM201 WAService.js:2)

    at r (VM201 WAService.js:2)

    at <anonymous>:4:16

    at p (VM201 WAService.js:2)

    at <anonymous>:9:7

    at evaluateRes (VM8 asdebug.js:1)

    at Object.invoke (VM8 asdebug.js:1)

    at r (VM8 asdebug.js:1)

    at T (VM201 WAService.js:2)

    at wa.batchInjectComponents (VM201 WAService.js:2)(env: macOS,mp,1.05.2110290; lib: 2.21.0)

(anonymous) @ VM220:12

evaluateRes @ VM8 asdebug.js:1

invoke @ VM8 asdebug.js:1

r @ VM8 asdebug.js:1

T @ VM201 WAService.js:2

batchInjectComponents @ VM201 WAService.js:2

injectComponentsRecursively @ VM201 WAService.js:2

va @ VM201 WAService.js:2

create @ VM201 WAService.js:2

sr @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

pr @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

K.emit @ VM201 WAService.js:2

emit @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

K.emit @ VM201 WAService.js:2

emit @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

c @ VM8 asdebug.js:1

u @ VM8 asdebug.js:1

(anonymous) @ VM8 asdebug.js:1

f @ VM8 asdebug.js:1

g @ VM8 asdebug.js:1

(anonymous) @ VM8 asdebug.js:1

_ws.onmessage @ VM8 asdebug.js:1

VM201 WAService.js:2 Error: module “@babel/runtime/helpers/typeof.js” is not defined

    at p (VM201 WAService.js:2)

    at r (VM201 WAService.js:2)

    at <anonymous>:4:16

    at p (VM201 WAService.js:2)

    at <anonymous>:9:7

    at evaluateRes (VM8 asdebug.js:1)

    at Object.invoke (VM8 asdebug.js:1)

    at r (VM8 asdebug.js:1)

    at T (VM201 WAService.js:2)

    at wa.batchInjectComponents (VM201 WAService.js:2)(env: macOS,mp,1.05.2110290; lib: 2.21.0)

errorReport @ VM201 WAService.js:2

thirdErrorReport @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

u @ VM201 WAService.js:2

a @ VM201 WAService.js:2

c @ VM8 asdebug.js:1

r @ VM8 asdebug.js:1

window.onerror @ VM194:1

evaluateRes @ VM8 asdebug.js:1

invoke @ VM8 asdebug.js:1

r @ VM8 asdebug.js:1

T @ VM201 WAService.js:2

batchInjectComponents @ VM201 WAService.js:2

injectComponentsRecursively @ VM201 WAService.js:2

va @ VM201 WAService.js:2

create @ VM201 WAService.js:2

sr @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

pr @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

K.emit @ VM201 WAService.js:2

emit @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

K.emit @ VM201 WAService.js:2

emit @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

c @ VM8 asdebug.js:1

u @ VM8 asdebug.js:1

(anonymous) @ VM8 asdebug.js:1

f @ VM8 asdebug.js:1

g @ VM8 asdebug.js:1

(anonymous) @ VM8 asdebug.js:1

_ws.onmessage @ VM8 asdebug.js:1

error (async)

t.default @ VM194:1

160 @ VM194:1

n @ VM194:1

(anonymous) @ VM194:1

(anonymous) @ VM194:1

Show 5 more frames

VM201 WAService.js:2 Error: module “@babel/runtime/helpers/typeof.js” is not defined

    at p (VM201 WAService.js:2)

    at r (VM201 WAService.js:2)

    at <anonymous>:4:16

    at p (VM201 WAService.js:2)

    at <anonymous>:9:7

    at evaluateRes (VM8 asdebug.js:1)

    at Object.invoke (VM8 asdebug.js:1)

    at r (VM8 asdebug.js:1)

    at T (VM201 WAService.js:2)

    at wa.batchInjectComponents (VM201 WAService.js:2)(env: macOS,mp,1.05.2110290; lib: 2.21.0)

errorReport @ VM201 WAService.js:2

thirdErrorReport @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

u @ VM201 WAService.js:2

a @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

emit @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

evaluateRes @ VM8 asdebug.js:1

invoke @ VM8 asdebug.js:1

r @ VM8 asdebug.js:1

T @ VM201 WAService.js:2

batchInjectComponents @ VM201 WAService.js:2

injectComponentsRecursively @ VM201 WAService.js:2

va @ VM201 WAService.js:2

create @ VM201 WAService.js:2

sr @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

pr @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

K.emit @ VM201 WAService.js:2

emit @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

K.emit @ VM201 WAService.js:2

emit @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

c @ VM8 asdebug.js:1

u @ VM8 asdebug.js:1

(anonymous) @ VM8 asdebug.js:1

f @ VM8 asdebug.js:1

g @ VM8 asdebug.js:1

(anonymous) @ VM8 asdebug.js:1

_ws.onmessage @ VM8 asdebug.js:1

error (async)

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

(anonymous) @ VM201 WAService.js:2

Show 5 more frames

1 回复

换成最新开发版

回到顶部