alibaba / weex

A framework for building Mobile cross-platform UI
https://weexapp.com/
Apache License 2.0
18.28k stars 2.13k forks source link

debug的时候报错 #2161

Closed xinxinshen closed 3 years ago

xinxinshen commented 7 years ago

安装了weex-toolkit 之后想进入调试模式,控制台输入命令后报错

weex debug hello.we

报错信息:

building...
 [webpack errors]
 /usr/local/lib/~/weex-toolkit/~/weex-devtool/~/weex-loader/lib/script.js!/Users/sxx/~/babel-loader/lib?presets[]=babel-preset-es2015&presets=babel-preset-es2015&plugins[]=babel-plugin-transform-runtime&plugins=babel-plugin-transform-runtime&comments=false!/usr/local/lib/~/weex-toolkit/~/weex-devtool/~/weex-loader/lib/extract.js?index=0&type=scripts!./hello.we
Module build failed: TypeError: /Users/sxx/Documents/learn/learnWeex/hello.we: Cannot read property 'indexOf' of undefined
    at Object.relative (/Users/sxx/node_modules/source-map/lib/util.js:206:15)
    at SourceMapConsumer_generatedPositionFor [as generatedPositionFor] (/Users/sxx/node_modules/source-map/lib/source-map-consumer.js:731:21)
    at /Users/sxx/node_modules/babel-core/lib/transformation/file/index.js:483:53
    at Array.forEach (native)
    at SourceMapConsumer_eachMapping [as eachMapping] (/Users/sxx/node_modules/source-map/lib/source-map-consumer.js:155:14)
    at /Users/sxx/node_modules/babel-core/lib/transformation/file/index.js:482:26
    at File.mergeSourceMap (/Users/sxx/node_modules/babel-core/lib/transformation/file/index.js:507:8)
    at File.generate (/Users/sxx/node_modules/babel-core/lib/transformation/file/index.js:706:25)
    at File.transform (/Users/sxx/node_modules/babel-core/lib/transformation/file/index.js:553:17)
    at /Users/sxx/node_modules/babel-core/lib/transformation/pipeline.js:50:19
 @ ./hello.we?entry=true 3:22-477 
luoei commented 7 years ago

indexOf是方法,具体看这里 http://www.w3school.com.cn/jsref/jsref_indexOf.asp

xinxinshen commented 7 years ago

不是很明白,我不进入调试模式的话,是不会报错的。 我的we文件如下,就是一个简单的hello world。

<template>
    <div static>
        <text>{{ word }}</text>
    </div>
</template>

<script>
    module.exports = {
        ready: function() {
            this.word = 'Data changes' // UI won't be updated
        },
        data: {
            word: 'Hello static'
        }
    }
</script>
luoei commented 7 years ago
<div static>
        <text>{{ word }}</text>
 </div>

不明白这个static有啥用?是不是这个字段的原因呢?

xinxinshen commented 7 years ago

讲道理,我把static去掉真的就可以了。why? @xispower

xinxinshen commented 7 years ago

有种不明觉厉的感觉

luoei commented 7 years ago

我的理解是,一般写这里的是属性,系统根据这个属性去做相应的事情,可能是因为你这里没有赋值的原因。赋值之后可以成为自定义的属性。

AllenVork commented 7 years ago

我只要文件里面有自定义的 component,就无法使用 weex hello.we 是怎么回事?

YorkShen commented 5 years ago

This PR/issue doesn't receive response since Weex migrated to Apache two years ago and this repository is no longer active yet.

Feel free to ask question in new repository and thanks for your contribution.

Hanks10100 commented 3 years ago

This issue is outdated for a long time and will be closed now. You can create a new one if you still have questions.