weex开发过程中遇到的问题总结

 

  • 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">

 

转载于:https://www.cnblogs.com/yklszm/p/8310915.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值