Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

weex create命令创建的项目,如果将默认we文件换成vue文件,web下报错

1、package.json

{
    "name": "xxx",
    "version": "1.0.0",
    "description": "a weex project",
    "main": "index.js",
    "scripts": {
        "build": "weex-builder src dist",
        "build_plugin": "webpack --config ./tools/webpack.config.plugin.js --color",
        "dev": "weex-builder src dist -w",
        "serve": "serve -p 8080"
    },
    "keywords": [
        "weex"
    ],
    "author": "fkysly@gmail.com",
    "license": "MIT",
    "devDependencies": {
        "babel-core": "^6.14.0",
        "babel-loader": "^6.2.5",
        "babel-preset-es2015": "^6.18.0",
        "vue-loader": "^10.0.2",
        "eslint": "^3.5.0",
        "serve": "^1.4.0",
        "webpack": "^1.13.2",
        "weex-vue-render": "latest",
        "weex-loader": "^0.3.3",
        "weex-builder": "^0.2.6"
    },
    "dependencies": {
        "weex-html5": "^0.3.2",
        "weex-components": "*"
    },
    "optionalDependencies": {
        "ios-deploy": "^1.9.0"
    }
}

web/index.html默认没改

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Weex HTML5</title>
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <meta name="apple-touch-fullscreen" content="yes" />
  <meta name="format-detection" content="telephone=no, email=no" />
  <style>
    html, body, #weex {
      width: 100%;
      height: 100%;
    }
  </style>
  <script src="../node_modules/weex-html5/dist/weex.js"></script>
</head>
<body>
  <div id="weex"></div>
  <script src="./index.js"></script>
</body>
</html>

src/index.vue

<template>
  <div class="wrapper">
    <text>text</text>
  </div>
</template>
<script>
  
  var navigator = weex.requireModule('navigator')
  var modal = weex.requireModule('modal')
  
</script>

npm run build
npm run serve
打开http://localhost:8080/web/ind...
控制台报错

Uncaught TypeError: weex.requireModule is not a function
    at Object.module.exports.calcTotal.sum (eval at init (http://localhost:8080/node_modules/weex-html5/dist/weex.js:3099:15), <anonymous>:136:23)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

你重新安装下 weex-toolkit吧,

weex uninstall weex-toolkit -g
weex install weex-toolkit -g

然后weex create vuedemo 的时候提醒安装最新的 weexpack 输入 y 即可。这样最新的weexpack create默认是 vue的模板了

clipboard.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...