电脑环境
OS win7
AS 3.1.4
开发工具WebStorm
我的配置步骤
- 在 components 下创建要跳转的页面 KGMainPage.vue
- 在 src 目录下创建 entry 文件夹,并在其中创建 KGMainPage.js 文件
代码如下
import store from '../store'
import mixins from '../mixins/index'
import * as filters from '../filter/filter'
import KGMainPage from '../components/KGMainPage.vue'
//sync(store, router)
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
// register global mixins.
Vue.mixin(mixins)
/* eslint-disable no-new */
new Vue(Vue.util.extend({el: '#root', store}, KGMainPage));
基本是复制了您Demo中的代码
- 在 webpack.commpn.conf.js 文件中配置 Entry 代码如下
const path = require('path');
const fs = require('fs-extra');
const webpack = require('webpack');
const config = require('./config');
const helper = require('./helper');
const glob = require('glob');
const vueLoaderConfig = require('./vue-loader.conf');
const vueWebTemp = helper.rootNode(config.templateDir);
const hasPluginInstalled = fs.existsSync(helper.rootNode(config.pluginFilePath));
const isWin = /^win/.test(process.platform);
const weexEntry = {
'index': helper.root('entry.js'),
'KGMainPage': helper.root('entry/KGMainPage.js')
};
包括在 entry.js 文件中通过 Vue.mixin( mixins )配置您写的跳转工具类 index.js
import mixins from '@/mixins/index'
// register global mixins.
Vue.mixin(mixins);
我基本完全按照您项目中的步骤进行配置,但配置完后出现了一些错误
错误详情:
通过 WeexPlayground 和 weex dev tool 进行调试发现错误如下(手机为 HUAWEI mate 10),界面一直在转圈,什么也没加载出来
Application onActivityPause()
Application to be in the backround
Warning :Component tree has not build completely,onActivityCreate can not be call!
Warning :Component tree has not build completely, onActivityResume can not be call!
end getBundleType type:Others time:3
reportJSException >>>> instanceId:12, exception function:createInstance, exception:Exception: TypeError: null is not an object (evaluating 'this._init')
Vue@(global function):39646:7
use@(weex framework):1:82551
(global function):34906:8
__webpack_require__@(global function):25:34
(global function):47990:33
__webpack_require__@(global function):25:34
(global function):68:37
(global function):69:12
anonymous@(global function):51351:7
(weex framework):1:40926
createInstance@(weex framework):1:40937
(weex framework):1:255299
我通过 weex run android 将 apk 安装到了手机(MX4),SplashActivity闪过后到 WXPageActivity 界面出错,屏幕显示 render error:2013 ,Logcat 报错如下
E/jsengine: ReportException : Exception: TypeError: null is not an object (evaluating 'this._init')
Vue@(global function):39645:7
use@(weex framework):2:30001
(global function):34905:8
__webpack_require__@(global function):24:34
(global function):47989:33
__webpack_require__@(global function):24:34
(global function):67:37
(global function):68:12
anonymous@(global function):51350:4
a@(weex framework):3:30112
(weex framework):8:22648
E/weex: reportJSException >>>> instanceId:3, exception function:createInstance, exception:Exception: TypeError: null is not an object (evaluating 'this._init')
Vue@(global function):39645:7
use@(weex framework):2:30001
(global function):34905:8
__webpack_require__@(global function):24:34
(global function):47989:33
__webpack_require__@(global function):24:34
(global function):67:37
(global function):68:12
anonymous@(global function):51350:4
a@(weex framework):3:30112
(weex framework):8:22648
并且我认真检查了半天,在 android assets 目录中发现了不同
-
MyProject
-
GSYGithubWeexApp
上述问题我 Baidu Google 了许久,未发现有用的信息,可能我的姿势不对,毕竟刚接触 weex Vue 不久,你的 踩坑系列博客我也看了,项目中的 question 也看了,但是无法解决这个问题,可能博主还是还做了其他的配置我没有发现,希望博主看到后能够及时回复下,谢谢了