1, 아이디어
우리는 급속한 발전에 도움이되는 해당 구성에 대해 잘 알고 신속하게 새로운 빛 제어의 전반적인 프레임 워크를 인수
2 분석 탈
로드하기 위해 H5
project.json 응용 프로그램 구성
//原生项目
{ "type": "vue",
"plugins": [
"jsnative"
],
"env": {
"product": {
"appBaseUrl": "xxxx/appServer/" //默认地址
}
}
}
네트워크 주소 구성
appBaseUrl
H5 시작
응용 프로그램을 실행하기위한 index.html을 진입 점
<html>
<head>
<title>和信基金</title>
<style/>
<link rel="stylesheet" href="./css/web.css">
</head>
<body>
<div class="wxmask"></div>
<div id="main">
<view id="index" /> //页面挂载
<view id="login" parent="index" async="true" />
<view id="home" home="true" parent="index" async="true"/>
</div>
<script src="app.js"></script>
</body>
<html>
코드 분석
(1), 주 등록에서 페이지를 작성하는 필요
에 해당하는 페이지 디렉토리 하역보기
2, 글로벌 CSS의 CSS / web.css
. 3, 정문 애플리케이션 app.js를
글로벌 범용 로직 정문을 app.js
import App from "light"
import service from '@/service/plugin';
App.Vue.use(service);
App.filter("start",function (next) {
//启动拦截器
App.log("app started...");
// 加载配置文件
service.load('./static/config.json').then(next)
}).filter("route",function (from, to, next) {
//视图拦截器
App.log(`view changed:${from.path}--${to.path}`);
next();
}).start();
1 애플리케이션이 시작되기 전에 차단
부하 (./static/config.json)는 데이터를로드하도록 구성 --- 시작
행 --- 로그 (뷰 변경 { from.path} - {to.path}) 인쇄 페이지 점프
plugin.load -> config.js / 설정 -> 설정 - generated.js
설정 구성로드 프로세스
plugin.load (./ 정적 / config.json)
config.js 코드
import configDynamic from './config-generated';
for (var key in configDynamic) {
config[key] = configDynamic[key];
}
export default config;
plugin.js 코드
import Light from "light"
import Config from '@/config';
load (url, timeout = 1000) {
return new Promise((resolve) => {
Light.fetch({
method: 'GET',
url: url,
type: 'json',
timeout: timeout
}, function (res) {
let config = res.ok && res.data ? res.data : {};
// 赋值到原配置文件,相同字段会被覆盖
for (var key in config) {
if (config[key]) {
Config[key] = config[key];
}
}
resolve(config);
// 加载配置文件失败
})
})
}
1, config.js 파일의 확장자는 매개 변수로 설정-generated.js 파일을로드2、json 赋值到原配置文件,相同字段会被覆盖 最终以“./static/config.json”为准
설치 자바 원시 코드
. GmuManager.getInstance () openGmu (SplashNetActivity.this, " GMU : // 주 ", NULL, NULL);
. GmuManager.getInstance () openGmu (SplashNetActivity.this, " GMU : 로그인 // ", NULL, NULL);
보기 / index.vue
init($);
홈 페이지로 이동