目前 app 使用 iframe+postmessage 实现微前端,用到时没问题,但想寻求下更好的解决方案,求大佬们分享下经验。
]]>import { LoginPage } from './../login/login/login'; import { AccountData } from './../../storages/account_data'; import { Component, Injectable } from '@angular/core'; import { NavController, NavParams, Platform, ViewController } from 'ionic-angular'; /* Generated class for the Base page. See http://ionicframework.com/docs/v2/components/#navigation for more info on Ionic pages and navigation. */ @Component({ selector: 'page-base', templateUrl: 'base.html' }) export abstract class BasePage { needLogin = false; constructor(protected accountData: AccountData, protected nav: NavController) { } push(page: any) { this.accountData.hasLoggedIn().subscribe(hasLoggedIn => { if (hasLoggedIn) { this.nav.push(page); } else { if (page.needLogin) { this.nav.push(LoginPage); } else { this.nav.push(page) } } }); } pop() { this.nav.pop(); } setRoot(page: any) { this.nav.setRoot(page); } }
继承该基类的:
import { AccountData } from './../../storages/account_data'; import { BasePage } from './../base/base'; import { Component } from '@angular/core'; import { NavController, NavParams } from 'ionic-angular'; /* Generated class for the Discover page. See http://ionicframework.com/docs/v2/components/#navigation for more info on Ionic pages and navigation. */ @Component({ selector: 'page-discover', templateUrl: 'discover.html' }) export class DiscoverPage extends BasePage { constructor(protected accountData: AccountData, protected navCtrl: NavController, ) { super(accountData, navCtrl); } }
运行ionic serve
后报错: Uncaught TypeError: Object prototype may only be an Object or null: undefined at setPrototypeOf ()
但是如果父类的构造方法为空的话一切正常,求解。
]]>$ sudo npm install -g ionic /usr/local/bin/ionic -> /usr/local/lib/node_modules/ionic/bin/ionic > node-sass@3.4.2 install /usr/local/lib/node_modules/ionic/node_modules/node-sass > node scripts/install.js shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied path.js:424 var path = (i >= 0) ? arguments[i] : process.cwd(); ^ Error: EACCES: permission denied, uv_cwd at Error (native) at Object.posix.resolve (path.js:424:50) at startup (node.js:91:32) at node.js:962:3 npm ERR! Darwin 15.3.0 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "ionic" npm ERR! node v4.3.1 npm ERR! npm v2.14.12 npm ERR! code ELIFECYCLE npm ERR! node-sass@3.4.2 install: `node scripts/install.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the node-sass@3.4.2 install script 'node scripts/install.js'. npm ERR! This is most likely a problem with the node-sass package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node scripts/install.js npm ERR! You can get their info via: npm ERR! npm owner ls node-sass npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /Users/elviscai/npm-debug.log
Ionicframework 一款免费的HTML5开源SDK,可以用来开发混合手机应用。
Ionichina 社区是全球最大的 Ionicframework 中文开源技术社区,致力于 Ionicframework 在中国的学习、推广、研究工作。
Ionichina 社区正在努力建设中,虽然我们还不牛×,但是请看我坚毅而纯洁的双眼,相信我们正在为了牛×而努力~
Ionichina 社区采用cnodejs社区开源的nodeclub框架搭建,并且已经得到了七牛的云存储和Ucloud的服务器、带宽赞助。
社区申请到了 Ionic 在中国地区组织者的身份,官方这篇博客里有介绍,其中提到 Ionic China就是本社区在维护。
Ionichina 社区街道办事处 (http://ionichina.com/)
敬上