Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序转H5,浏览器提示找不到Nerv对象 #3158

Closed
xiaoboJoin opened this issue May 23, 2019 · 10 comments
Closed

小程序转H5,浏览器提示找不到Nerv对象 #3158

xiaoboJoin opened this issue May 23, 2019 · 10 comments
Assignees

Comments

@xiaoboJoin
Copy link

小程序转H5,浏览器提示找不到Nerv对象,转换成功了,
Compiled successfully!

但是H5打开的时候报错
1558605631600

@taro-bot
Copy link

taro-bot bot commented May 23, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@luckyadam
Copy link
Member

luckyadam commented May 23, 2019

taro 版本多少,再贴一下你的 app.js 代码

@ybingyu
Copy link

ybingyu commented Jun 3, 2019

同样的问题。taro 版本 1.3.0-beta.5
image

@Garfield550
Copy link
Collaborator

升级一下 v1.3.0-beta.6 然后把 package.json 的 Nerv 和 Nerv-DevTools 版本改成 ^1.4.0-beta.5 试试。(只是建议

@ybingyu
Copy link

ybingyu commented Jun 3, 2019

已经升级了 v1.3.0-beta.6. 仍然在dev:h5 或者 build:h5的时候提示 Nerv not define。在app.js 添加 ‘’import Nerv from "nervjs"; 才可以

@loosenRogers
Copy link

你好 你这个问题解决了么
你的流程是微信小程序 -> taro -> h5吧
这个流程的流程的话 我也遇到同样的问题issue#3398
看你这个提的还的还蛮早的,官方一直没解决啊

@Littly
Copy link
Contributor

Littly commented Jun 16, 2019

贴一下转换后的 app.js 代码看看?

@loosenRogers
Copy link

loosenRogers commented Jun 17, 2019

贴一下转换后的 app.js 代码看看?

以下是微信小程序官方组件demo picker的转换成h5的app.js文件内容
头部引入Taro,但是在其中用的Nerv.render()方法,所以报错

import Taro from "@tarojs/taro-h5";

import './app.scss';

import { Router, createHistory, mountApis } from '@tarojs/router';
Taro.initPxTransform({
  "designWidth": 750,
  "deviceRatio": {
    "640": 1.17,
    "750": 1,
    "828": 0.905
  }
});

const _taroHistory = createHistory({
  mode: "hash",
  basename: "/",
  customRoutes: {},
  firstPagePath: "/index/index"
});

mountApis(_taroHistory);
class App extends Taro.Component {
  componentWillMount = () => {};
  config = {
    pages: ["/index/index"],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: 'WeChat',
      navigationBarTextStyle: 'black'
    },
    sitemapLocation: 'sitemap.json'
  };

  componentWillMount() {
    this.$app.globalData = this.globalData;
  }

  render() {
    return <Router history={_taroHistory} routes={[{
      path: '/index/index',
      componentLoader: () => import( /* webpackChunkName: "index_index" */'./index/index'),
      isIndex: true
    }]} customRoutes={{}} />;
  }

  constructor(props, context) {
    super(props, context);
    Taro._$app = this;
  }

}

export default App;
Nerv.render(<App />, document.getElementById('app'));

@yuche yuche added the H5 label Jul 16, 2019
@taro-bot
Copy link

taro-bot bot commented Jul 16, 2019

CC @Littly

@loosenRogers
Copy link

之前1.3.2版本还是有的;发布新版本后,这个问题好像已经没有再复现了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants