javascript - weex的BroadcastChannel使用无效

 JIE9118_755 发布于 2022-11-09 20:12

别人说把用BroadcastChannel的文件从vue改为we就可以了。我改了以后就不行了。大家帮我看哪里配置错了。

var path = require('path')
var webpack = require('webpack')
require('weex-loader');

var bannerPlugin = new webpack.BannerPlugin(
  '// { "framework": "Vue" }\n',
  { raw: true }
)

function getBaseConfig () {
  return {
    entry: {
      'index': path.resolve('src', 'entry.js')
    },
    output: {
      path: 'dist',
    },
    module: {
      loaders: [
        {
          test: /\.js$/,
          loader: 'babel',
          exclude: /node_modules/
        }, {
          test: /\.vue(\?[^?]+)?$/,
          loaders: []
        },{
          test: /\.we(\?[^?]+)?$/
          , loaders: ['weex-loader']
      }]
    },
    plugins: [bannerPlugin]
  }
}

var webConfig = getBaseConfig()
webConfig.output.filename = '[name].web.js'
webConfig.module.loaders[1].loaders.push('vue')

var weexConfig = getBaseConfig()
weexConfig.output.filename = '[name].weex.js'
weexConfig.module.loaders[1].loaders.push('weex')
// import Vue from 'vue'
import Router from 'vue-router'
import StoriesView from './views/StoriesView.vue'
import ArticleView from './views/ArticleView.vue'
import CommentView from './views/CommentView.vue'
import UserView from './views/UserView.vue'
import DemoView from './WeexDemo/total.vue'
import first from './WeexDemo/first.vue'
import second from './WeexDemo/second.vue'
import three from './WeexDemo/three.vue'
import four from './WeexDemo/four.vue'


Vue.use(Router)

// Story view factory
function createStoriesView (type) {
  return {
    name: `${type}-stories-view`,
    render (createElement) {
      return createElement(StoriesView, { props: { type }})
    }
  }
}

export default new Router({
  // mode: 'abstract',
  routes: [
    { path: '/top', component: createStoriesView('top') },
    { path: '/new', component: createStoriesView('new') },
    { path: '/show', component: createStoriesView('show') },
    { path: '/ask', component: createStoriesView('ask') },
    { path: '/job', component: createStoriesView('job') },
    { path: '/demo', component: DemoView},
    { path: '/first', component:first},
    { path: '/second', component:second},
     { path: '/three', component:three},
     { path: '/four', component:four},
    { path: '/article/:url(.*)?', component: ArticleView },
    { path: '/item/:id(\\d+)', component: CommentView },
    { path: '/user/:id', component: UserView },
    { path: '/', redirect: '/top' }
  ]
})

直接把total.vue改为total.we就不行了。求大家帮我看看。

1 个回答
  • 没见到代码里有 BroadcastChannel 啊。

    另外,.we 和 .vue 是两种语法,内部用的框架不一样,打包方式也不一样的,直接改后缀名肯定是不行的。

    2022-11-12 11:03 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有