omix - add new argument to definePage
This commit is contained in:
parent
2a3fc7a9d2
commit
ebab0c6590
|
@ -14,10 +14,6 @@ const WeElement = Component
|
|||
|
||||
|
||||
|
||||
function render(){
|
||||
|
||||
}
|
||||
|
||||
function VNode() {}
|
||||
|
||||
const stack = []
|
||||
|
@ -90,10 +86,23 @@ function getGlobal() {
|
|||
}
|
||||
|
||||
const root = getGlobal()
|
||||
console.log(root)
|
||||
const mapping = {}
|
||||
let config = {}
|
||||
|
||||
const definePage =define
|
||||
const defineApp = define
|
||||
const definePage = function(name, ctor, path ){
|
||||
mapping[path] ={
|
||||
name,
|
||||
ctor
|
||||
}
|
||||
}
|
||||
const defineApp = function(a,b){
|
||||
const ins = new b()
|
||||
config = ins.config
|
||||
}
|
||||
|
||||
function render(){
|
||||
console.error(mapping[config.pages[0]])
|
||||
}
|
||||
|
||||
root.Omi = {
|
||||
define,
|
||||
|
|
|
@ -770,6 +770,12 @@ function parseAst (type, ast, depComponents, sourceFilePath, filePath, npmSkip =
|
|||
case PARSE_AST_TYPE.PAGE:
|
||||
if (buildAdapter === Util.BUILD_TYPES.WEAPP) {
|
||||
//@fix 注释掉用来解决小程序报错
|
||||
const arr = sourceFilePath.split('/')
|
||||
const path = arr[arr.length - 3] + '/' + arr[arr.length - 2] + '/' + arr[arr.length-1].split('.')[0]
|
||||
const obj = JSON.parse(JSON.stringify(node.body[node.body.length-1].expression.arguments[0]))
|
||||
obj.value = path
|
||||
//给 define 增加第三个参数
|
||||
node.body[node.body.length-1].expression.arguments.push(obj)
|
||||
node.body[node.body.length-1].expression.callee.name = 'global.Omi.definePage'
|
||||
//node.body.push(template(`Component(require('${taroMiniAppFrameworkPath}').default.createComponent(${exportVariableName}, true))`, babylonConfig)())
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue