- weex src/index.vue 前需要先执行
npm run dev & npm run serve
Error: Can't resolve 'weex-ui/packages/wxc-icon/style.css' 由于 babel-plugin-component有一个大版本升级,新加入了style,
---->解决办法:需要在原有.babelrc中加入
"style": false
- .xtoolkit/config.json 找不到
---->解决办法:手动添加该文件
- Navigator跳转失败报错:android.os.FileUriExposedException: file://assets/dist/pages/login.js exposed beyond app through Intent.getData()
----->解决办法:在application 的onCreate()的方法中加入;
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.setVmPolicy(builder.build()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { builder.detectFileUriExposure(); }
- 无法使用navigator打开新页面
----->解决办法:在WXPageActivity的onCreate方法中增加红色部分代码
if(TextUtils.equals("file",uri.getScheme())){
mUri = Uri.parse(uri.toString());
}
if (mUri == null) {
mUri = Uri.parse(AppConfig.getLaunchUrl());
}
if (!WXSoInstallMgrSdk.isCPUSupport()) {
mProgressBar.setVisibility(View.INVISIBLE);
mTipView.setText(R.string.cpu_not_support_tip);
return;
}
在vue文件里面使用,即可完成跳转
navigator.push({ url: 'file://assets/dist/home.js', animated: "true" }, event => { //modal.toast({ message: 'callback: ' + event }) })
- weex页面传参问题
----->解决办法:在native中修改AbsWeexActivity的renderPageByURL,增加如下代码(红色):
protected void renderPageByURL(String url, String jsonInitData) { CommonUtils.throwIfNull(mContainer, new RuntimeException("Can't render page, container is null")); Map<String, Object> options = new HashMap<>(); options.put(WXSDKInstance.BUNDLE_URL, url); //vine add Uri uri = Uri.parse(url); Set<String> set = uri.getQueryParameterNames(); for (String paramName: set) { String paramValue = uri.getQueryParameter(paramName); options.put(paramName, paramValue); }
在vue文件中使用
this.$getConfig()
来获取参数
module.exports = { data: { aa: '', bb: '', bundleUrl: '' }, methods: { // 获取 native的传参 getOptions: function() { this.aa = this.$getConfig().aa; this.bb = this.$getConfig().bb; this.bundleUrl = this.$getConfig().bundleUrl; } } }
- 去默认顶部导航
---->解决办法:在AndroidManifest.xml中设置主题为NoActionBar
<activity android:name="com.weex.app.WXPageActivity" android:label="@string/app_name" android:screenOrientation="portrait" android:theme="@style/AppTheme.NoActionBar">