diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js
index d42f41bbbe2c03407f1920426b143f2fb4423a6e..c868527bc85a9a81c7477cac953e21c257ac220b 100644
--- a/packages/uni-app-plus/dist/index.js
+++ b/packages/uni-app-plus/dist/index.js
@@ -1156,7 +1156,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
];
function parseBaseApp (vm, {
diff --git a/packages/uni-cli-shared/lib/theme.js b/packages/uni-cli-shared/lib/theme.js
new file mode 100644
index 0000000000000000000000000000000000000000..809c5555f6bee63a11bdc1243439dd797fc63bc5
--- /dev/null
+++ b/packages/uni-cli-shared/lib/theme.js
@@ -0,0 +1,59 @@
+const fs = require('fs')
+const path = require('path')
+
+const {
+ getJson
+} = require('./json')
+
+function parseThemeByJsonStr (jsonStr, keys, theme) {
+ if (jsonStr.indexOf('@') === -1) {
+ return jsonStr
+ }
+ keys.forEach(key => {
+ jsonStr = jsonStr.replace(new RegExp('@' + key, 'g'), theme[key])
+ })
+ return jsonStr
+}
+
+const themeJsonPath = path.join(process.env.UNI_INPUT_DIR, 'theme.json')
+
+function hasTheme () {
+ return fs.existsSync(themeJsonPath)
+}
+
+function darkmode () {
+ return !!(global.uniPlugin.options || {}).darkmode
+}
+
+module.exports = {
+ darkmode,
+ hasTheme,
+ initTheme () {
+ if (!hasTheme()) {
+ return
+ }
+ if (darkmode()) {
+ return
+ }
+ try {
+ const theme = getJson('theme.json', true)
+ global.uniPlugin.defaultTheme = theme.light
+ } catch (e) {
+ console.error(e)
+ }
+ },
+ parseTheme (json) {
+ const theme = global.uniPlugin.defaultTheme
+ if (!theme) {
+ return json
+ }
+ const keys = Object.keys(theme)
+ if (!keys.length) {
+ return json
+ }
+ if (typeof json === 'string') {
+ return parseThemeByJsonStr(json, keys, theme)
+ }
+ return JSON.parse(parseThemeByJsonStr(JSON.stringify(json), keys, theme))
+ }
+}
diff --git a/packages/uni-mp-alipay/dist/index.js b/packages/uni-mp-alipay/dist/index.js
index 9894a8e41e0cfb9e02608c3a9fb524922bb5507b..7a497e8d2e9dfd9fe1ab96577a775ee551601385 100644
--- a/packages/uni-mp-alipay/dist/index.js
+++ b/packages/uni-mp-alipay/dist/index.js
@@ -1633,7 +1633,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
];
function parseBaseApp (vm, {
diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js
index 7b53c18b7d8d6848c3956a34c25b4a092a997079..d534b60cf873483b67c461fe681da9c63f81a4e0 100644
--- a/packages/uni-mp-baidu/dist/index.js
+++ b/packages/uni-mp-baidu/dist/index.js
@@ -1298,7 +1298,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
];
function parseBaseApp (vm, {
diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js
index be9a43ac9da8b4cf693b09e60e00484290d2d69a..1af6867cb4f745337f88baa527d0f9f5be6a8db9 100644
--- a/packages/uni-mp-qq/dist/index.js
+++ b/packages/uni-mp-qq/dist/index.js
@@ -1214,7 +1214,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
];
function parseBaseApp (vm, {
diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js
index 817ba29cd75fb92aca2a572358dd08c87c5625ad..c62d77aa74f614d7c771eae7cd1abedba1369569 100644
--- a/packages/uni-mp-toutiao/dist/index.js
+++ b/packages/uni-mp-toutiao/dist/index.js
@@ -1306,7 +1306,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
];
function parseBaseApp (vm, {
diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js
index 630ee9c45681053ebaa59f789853422ce2e53604..b40686e6557309ddd4b2ed8b46733d1fb2de1264 100644
--- a/packages/uni-mp-weixin/dist/index.js
+++ b/packages/uni-mp-weixin/dist/index.js
@@ -1171,7 +1171,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
];
function parseBaseApp (vm, {
diff --git a/packages/uni-mp-weixin/lib/uni.config.js b/packages/uni-mp-weixin/lib/uni.config.js
index c806a821ba4102b41b30f89301b1fe597bfc37e3..6a67b8a8279f804a64857665019dd7f425dbbd0e 100644
--- a/packages/uni-mp-weixin/lib/uni.config.js
+++ b/packages/uni-mp-weixin/lib/uni.config.js
@@ -17,10 +17,12 @@ module.exports = {
},
filterTag: 'wxs',
project: 'project.config.json',
- subPackages: true
+ subPackages: true,
+ darkmode: true
},
copyWebpackOptions (platformOptions, vueOptions) {
- const copyOptions = [
+ const copyOptions = [
+ 'theme.json',
'sitemap.json',
'ext.json',
'custom-tab-bar'
diff --git a/packages/uni-quickapp-webview/dist/index.js b/packages/uni-quickapp-webview/dist/index.js
index c190f161d3edbe0ee1fb458b2bbced592611a9c9..383f4cf29ea16b7cf41233f85ab4e11da902d435 100644
--- a/packages/uni-quickapp-webview/dist/index.js
+++ b/packages/uni-quickapp-webview/dist/index.js
@@ -1156,7 +1156,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
];
function parseBaseApp (vm, {
diff --git a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
index b82875fde8ed353a5b6dab6a06360140823e4d5a..11add830b291bbb680a7524abcba5b0f9e932f27 100644
--- a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js
@@ -251,10 +251,10 @@ describe('mp:compiler-extra', () => {
)
})
- it('generate events inside v-for', () => {
- assertCodegen(
- '',
- ''
+ it('generate events inside v-for', () => {
+ assertCodegen(
+ '',
+ ''
)
// TODO vue的数字 item 是从1,小程序是从0,后续考虑抹平差异
assertCodegen(
@@ -310,23 +310,23 @@ describe('mp:compiler-extra', () => {
assertCodegen(
'',
''
- )
- assertCodegen(
- `
-
-
-
- `,
- ''
- )
- assertCodegen(
- '',
- ''
- )
- assertCodegen(
- '',
- ''
- )
+ )
+ assertCodegen(
+ `
+
+
+
+ `,
+ ''
+ )
+ assertCodegen(
+ '',
+ ''
+ )
+ assertCodegen(
+ '',
+ ''
+ )
})
it('generate class binding', () => {
@@ -586,6 +586,17 @@ describe('mp:compiler-extra', () => {
'{{item.g0}}',
'with(this){var l0=__map(list,function(item,i){var g0=item.split("").join(" ");return{$orig:__get_orig(item),g0:g0}});$mp.data=Object.assign({},{$root:{l0:l0}})}'
)
+ assertCodegen(
+ `
+
+
+ {{formatIt(item2.id)}}
+
+
+ `,
+ '{{\'\'+item2.m0+\'\'}}',
+ 'with(this){var l1=__map(tabList,function(item,index){var l0=__map(list[item.key],function(item2,index2){var m0=formatIt(item2.id);return{$orig:__get_orig(item2),m0:m0}});return{$orig:__get_orig(item),l0:l0}});$mp.data=Object.assign({},{$root:{l1:l1}})}'
+ )
})
it('generate TemplateLiteral ', () => {
@@ -600,11 +611,11 @@ describe('mp:compiler-extra', () => {
''
)
})
- it('generate event ', () => {
- assertCodegen(
- '',
- ''
- )
+ it('generate event ', () => {
+ assertCodegen(
+ '',
+ ''
+ )
assertCodegen(
'{{item.title}}',
@@ -654,15 +665,15 @@ describe('mp:compiler-extra', () => {
'{{ item }}',
'{{item}}'
)
- })
- it('generate bool attr', () => {
- assertCodegen(
- '',
- ''
- )
- assertCodegen(
- '',
- ''
- )
+ })
+ it('generate bool attr', () => {
+ assertCodegen(
+ '',
+ ''
+ )
+ assertCodegen(
+ '',
+ ''
+ )
})
})
diff --git a/packages/uni-template-compiler/lib/script/traverse/render-list.js b/packages/uni-template-compiler/lib/script/traverse/render-list.js
index de40449810ca61f7fffb749572fb1477af9b23f3..e302bd3774101389efb6e29e0afaaa36877d65b1 100644
--- a/packages/uni-template-compiler/lib/script/traverse/render-list.js
+++ b/packages/uni-template-compiler/lib/script/traverse/render-list.js
@@ -146,6 +146,7 @@ module.exports = function traverseRenderList (path, state) {
identifierArray: state.identifierArray,
propertyArray: [],
declarationArray: [],
+ computedProperty: {},
initExpressionStatementArray: state.initExpressionStatementArray
}
@@ -173,6 +174,16 @@ module.exports = function traverseRenderList (path, state) {
functionExpression.traverse(origVisitor, {
forItem
})
+ const keys = Object.keys(forState.computedProperty)
+ if (keys.length) {
+ keys.forEach(key => {
+ const property = forState.computedProperty[key]
+ if (t.isMemberExpression(property) && property.object.name === forItem) {
+ property.object = t.memberExpression(t.identifier(forItem), t.identifier(VAR_ORIGINAL))
+ forState.options.replaceCodes[key] = `'+${genCode(property, true)}+'`
+ }
+ })
+ }
} else {
forPath.traverse(require('./visitor'), forState)
}
diff --git a/packages/uni-template-compiler/lib/util.js b/packages/uni-template-compiler/lib/util.js
index a82eaba52c9037e2e902b4d17f020f3159786ba7..fc3b2a3f4de1694bfea17614dfd867c4af634d18 100644
--- a/packages/uni-template-compiler/lib/util.js
+++ b/packages/uni-template-compiler/lib/util.js
@@ -133,6 +133,9 @@ function processMemberProperty (node, state) {
}
const identifier = '__$m' + (state.options.__m__++) + '__'
state.options.replaceCodes[identifier] = `'+${genCode(property, true)}+'`
+ if (state.computedProperty) {
+ state.computedProperty[identifier] = property
+ }
node.property = t.identifier(identifier)
}
node.computed = false
diff --git a/packages/vue-cli-plugin-hbuilderx/build/css-loader.conf.js b/packages/vue-cli-plugin-hbuilderx/build/css-loader.conf.js
index e2719ddfef884668ee44cdab616160c8843b2ff9..ac354fa36db37794c36487fe254e264e95b9d952 100644
--- a/packages/vue-cli-plugin-hbuilderx/build/css-loader.conf.js
+++ b/packages/vue-cli-plugin-hbuilderx/build/css-loader.conf.js
@@ -71,20 +71,20 @@ const sassLoader = {
if (sassLoaderVersion < 8) {
scssLoader.options.data = sassData
- scssLoader.options.outputStyle = 'nested'
+ scssLoader.options.outputStyle = 'expanded'
sassLoader.options.data = sassData
- sassLoader.options.outputStyle = 'nested'
+ sassLoader.options.outputStyle = 'expanded'
sassLoader.options.indentedSyntax = true
} else {
scssLoader.options.prependData = sassData
scssLoader.options.sassOptions = {
- outputStyle: 'nested'
+ outputStyle: 'expanded'
}
sassLoader.options.prependData = sassData
sassLoader.options.sassOptions = {
- outputStyle: 'nested',
+ outputStyle: 'expanded',
indentedSyntax: true
}
}
diff --git a/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js b/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
index b6bf7cad5734d4b380e2e4895b8c3948fba916d3..e3d8735d8325d6563752dea7a7be82206ecc7549 100644
--- a/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
+++ b/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js
@@ -5600,6 +5600,15 @@ function cloneWithData(vm) {
ret[key] = vm[key];
return ret
}, ret);
+
+ // vue-composition-api
+ var rawBindings = vm.__secret_vfa_state__ && vm.__secret_vfa_state__.rawBindings;
+ if (rawBindings) {
+ Object.keys(rawBindings).forEach(function (key) {
+ ret[key] = vm[key];
+ });
+ }
+
//TODO 需要把无用数据处理掉,比如 list=>l0 则 list 需要移除,否则多传输一份数据
Object.assign(ret, vm.$mp.data || {});
if (
@@ -5804,7 +5813,7 @@ function getTarget(obj, path) {
return getTarget(obj[key], parts.slice(1).join('.'))
}
-function internalMixin(Vue ) {
+function internalMixin(Vue) {
Vue.config.errorHandler = function(err, vm, info) {
Vue.util.warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
@@ -5952,6 +5961,8 @@ var LIFECYCLE_HOOKS$1 = [
'onShow',
'onHide',
'onUniNViewMessage',
+ 'onPageNotFound',
+ 'onThemeChange',
'onError',
//Page
'onLoad',
diff --git a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
index ff5340bfe883620416b6b95ce0caeb8736612d46..e30347e92804acb648296a052233b9a41ae3c78a 100644
--- a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
+++ b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/util.js
@@ -19,7 +19,8 @@ function parseComponents (content, traverse) {
components: [],
options: {
name: null,
- inheritAttrs: null
+ inheritAttrs: null,
+ props: null
}
})
return {
@@ -30,4 +31,4 @@ function parseComponents (content, traverse) {
module.exports = {
parseComponents
-}
+}
diff --git a/packages/webpack-uni-mp-loader/__tests__/components.spec.js b/packages/webpack-uni-mp-loader/__tests__/components.spec.js
index e4e1a7132c358b74951b4f58f2fadf39098f2876..cbe2109b90a02f1cbc40f7f87176009c56b76db9 100644
--- a/packages/webpack-uni-mp-loader/__tests__/components.spec.js
+++ b/packages/webpack-uni-mp-loader/__tests__/components.spec.js
@@ -22,6 +22,28 @@ function assertCodegen (content, expectedComponents, isScoped = true) {
expect(JSON.stringify(components)).toBe(JSON.stringify(expectedComponents))
}
+function assertCodegenOptions (content, expectedOptions, isScoped = true) {
+ const {
+ state: {
+ options
+ }
+ } = (isScoped ? scopedComponentTraverse : globalComponentTraverse)(parser.parse(content, {
+ sourceType: 'module',
+ plugins: [
+ 'typescript'
+ ]
+ }), {
+ components: [],
+ options: {
+ name: null,
+ inheritAttrs: null,
+ props: null
+ }
+ })
+
+ expect(JSON.stringify(options)).toBe(JSON.stringify(expectedOptions))
+}
+
describe('mp:loader', () => {
it('parse scoped component', () => {
assertCodegen(
@@ -153,6 +175,46 @@ global['__wxVueOptions'] = {
source: '@/components/my-button/my-button.vue'
}
])
+
+ assertCodegenOptions(
+ `export default {
+ name: 'test'
+ }`,
+ {
+ name: '"test"',
+ inheritAttrs: null,
+ props: null
+ }
+ )
+
+ assertCodegenOptions(
+ `export default {
+ props: ['id', 'test']
+ }`,
+ {
+ name: null,
+ inheritAttrs: null,
+ props: '["id","test"]'
+ }
+ )
+
+ assertCodegenOptions(
+ `export default {
+ props: {
+ id: {
+ type: String
+ },
+ 'test': {
+ type: String
+ }
+ }
+ }`,
+ {
+ name: null,
+ inheritAttrs: null,
+ props: '["id","test"]'
+ }
+ )
})
it('parse global component', () => {
diff --git a/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js b/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
index 42e320568a4f5e96d6ee3fcd0784b9f868c7535d..b6ee2b10ad6fd2e71eeae5e4e66e965f1d1dd627 100644
--- a/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
+++ b/packages/webpack-uni-mp-loader/lib/babel/scoped-component-traverse.js
@@ -6,7 +6,7 @@ const {
} = require('./util')
function handleObjectExpression (declaration, path, state) {
- if (state.options) { // name,inheritAttrs
+ if (state.options) { // name,inheritAttrs,props
Object.keys(state.options).forEach(name => {
const optionProperty = declaration.properties.filter(prop => {
return t.isObjectProperty(prop) &&
@@ -14,7 +14,21 @@ function handleObjectExpression (declaration, path, state) {
prop.key.name === name
})[0]
if (optionProperty) {
- if (t.isStringLiteral(optionProperty.value)) {
+ if (name === 'props') {
+ if (t.isArrayExpression(optionProperty.value)) {
+ state.options[name] = JSON.stringify(optionProperty.value.elements.filter(element => t.isStringLiteral(element)).map(({ value }) => value))
+ } else if (t.isObjectExpression(optionProperty.value)) {
+ const props = []
+ optionProperty.value.properties.forEach(({ key }) => {
+ if (t.isIdentifier(key)) {
+ props.push(key.name)
+ } else if (t.isStringLiteral(key)) {
+ props.push(key.value)
+ }
+ })
+ state.options[name] = JSON.stringify(props)
+ }
+ } else if (t.isStringLiteral(optionProperty.value)) {
state.options[name] = JSON.stringify(optionProperty.value.value)
} else {
state.options[name] = optionProperty.value.value
diff --git a/packages/webpack-uni-pages-loader/lib/index-new.js b/packages/webpack-uni-pages-loader/lib/index-new.js
index b061af11b3a0d3dbf43064908a8a7816155450b8..72b63c3f6ac997a2d08f675aed8bf7678b8fe4fc 100644
--- a/packages/webpack-uni-pages-loader/lib/index-new.js
+++ b/packages/webpack-uni-pages-loader/lib/index-new.js
@@ -16,6 +16,11 @@ const {
updateProjectJson
} = require('@dcloudio/uni-cli-shared/lib/cache')
+const {
+ initTheme,
+ parseTheme
+} = require('@dcloudio/uni-cli-shared/lib/theme')
+
const {
// pagesJsonJsFileName,
initAutoImportComponents
@@ -35,6 +40,8 @@ function renameUsingComponents (jsonObj) {
module.exports = function (content, map) {
this.cacheable && this.cacheable()
+ initTheme()
+
let isAppView = false
if (this.resourceQuery) {
const params = loaderUtils.parseQuery(this.resourceQuery)
@@ -48,13 +55,18 @@ module.exports = function (content, map) {
// this.addDependency(pagesJsonJsPath)
this.addDependency(manifestJsonPath)
- const pagesJson = parsePagesJson(content, {
+ let pagesJson = parsePagesJson(content, {
addDependency: (file) => {
(process.UNI_PAGES_DEPS || (process.UNI_PAGES_DEPS = new Set())).add(normalizePath(file))
this.addDependency(file)
}
})
+ if (global.uniPlugin.defaultTheme) {
+ pagesJson = parseTheme(pagesJson)
+ this.addDependency(path.resolve(process.env.UNI_INPUT_DIR, 'theme.json'))
+ }
+
// 组件自动导入配置
process.UNI_AUTO_SCAN_COMPONENTS = !(pagesJson.easycom && pagesJson.easycom.autoscan === false)
initAutoImportComponents(pagesJson.easycom)
diff --git a/packages/webpack-uni-pages-loader/lib/platforms/mp.js b/packages/webpack-uni-pages-loader/lib/platforms/mp.js
index 1eb16d01242a56e41381c8895811e51b629f52e8..0ee26bc9fdf3c8c759179cbe18656063fe49b7c3 100644
--- a/packages/webpack-uni-pages-loader/lib/platforms/mp.js
+++ b/packages/webpack-uni-pages-loader/lib/platforms/mp.js
@@ -12,6 +12,11 @@ const {
updateAppJsonUsingComponents
} = require('@dcloudio/uni-cli-shared/lib/cache')
+const {
+ darkmode,
+ hasTheme
+} = require('@dcloudio/uni-cli-shared/lib/theme')
+
const {
hasOwn,
parseStyle
@@ -208,6 +213,11 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
updateAppJsonUsingComponents(app.usingComponents)
}
+ if (darkmode() && hasTheme()) {
+ app.darkmode = true
+ app.themeLocation = 'theme.json'
+ }
+
const projectName = getPlatformProject()
const projectPath = projectName && path.resolve(process.env.VUE_CLI_CONTEXT || process.cwd(), projectName)
@@ -309,4 +319,4 @@ module.exports = function (pagesJson, manifestJson, project = {}) {
}
}
}
-}
+}
diff --git a/packages/webpack-uni-pages-loader/lib/util.js b/packages/webpack-uni-pages-loader/lib/util.js
index 8598d2c4b30d969d58982b7dbcb1b0036439b147..47cd573f9a58ac2a187a85b202cc1db9516bc128 100644
--- a/packages/webpack-uni-pages-loader/lib/util.js
+++ b/packages/webpack-uni-pages-loader/lib/util.js
@@ -74,7 +74,13 @@ function parseStyle (style = {}, root = '') {
return Object.assign(windowOptions, platformStyle)
}
- if (style.navigationBarTextStyle && style.navigationBarTextStyle !== 'black') {
+ if (
+ style.navigationBarTextStyle &&
+ (
+ style.navigationBarTextStyle !== 'black' &&
+ style.navigationBarTextStyle.indexOf('@') !== 0
+ )
+ ) {
style.navigationBarTextStyle = 'white'
}
diff --git a/src/core/service/plugins/lifecycle.js b/src/core/service/plugins/lifecycle.js
index 575959515ce1b3dfdf2bae017b393f4b5e10a280..d2512177102d57ab9653620be3fdf23395d3d2af 100644
--- a/src/core/service/plugins/lifecycle.js
+++ b/src/core/service/plugins/lifecycle.js
@@ -6,7 +6,8 @@ const LIFECYCLE_HOOKS = [
'onShow',
'onHide',
'onUniNViewMessage',
- 'onPageNotFound',
+ 'onPageNotFound',
+ 'onThemeChange',
'onError',
// Page
'onLoad',
diff --git a/src/core/view/plugins/wxs/component-descriptor.js b/src/core/view/plugins/wxs/component-descriptor.js
index 5a5defb4c7533e45e16a21ea192344ebc81080c9..04d4e4ec50bf79f23bab078a0a80094f574d166f 100644
--- a/src/core/view/plugins/wxs/component-descriptor.js
+++ b/src/core/view/plugins/wxs/component-descriptor.js
@@ -125,6 +125,13 @@ class ComponentDescriptor {
return this.$el && this.$el.classList.contains(cls)
}
+ getComputedStyle () {
+ if (this.$el) {
+ return window.getComputedStyle(this.$el)
+ }
+ return {}
+ }
+
getDataset () {
return this.$el && this.$el.dataset
}
diff --git a/src/platforms/app-plus/service/api/plugin/sub-nvue.js b/src/platforms/app-plus/service/api/plugin/sub-nvue.js
index 3d710f7a37928fdf11b5612811cbf54de64fbcf5..f398d6f1165cde13f9cc0cc88fa8f7e6f959f7a0 100644
--- a/src/platforms/app-plus/service/api/plugin/sub-nvue.js
+++ b/src/platforms/app-plus/service/api/plugin/sub-nvue.js
@@ -62,7 +62,10 @@ function wrapper (webview) {
}
export function getSubNVueById (id) {
- const webview = plus.webview.getWebviewById(id)
+ const webview = plus.webview.getWebviewById(id)
+ if (webview === null || webview === undefined) {
+ throw new Error('Unable to find SubNVue, id=' + id)
+ }
if (webview && !webview.$processed) {
wrapper(webview)
}
diff --git a/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js b/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
index f0fea7f2879fa9b3b5964b77264f96c250572c7f..faaecadfb84952f5f28f723fd254f2f360d0808d 100644
--- a/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
+++ b/src/platforms/mp-weixin/runtime/wrapper/app-base-parser.js
@@ -9,7 +9,8 @@ const hooks = [
'onShow',
'onHide',
'onError',
- 'onPageNotFound'
+ 'onPageNotFound',
+ 'onThemeChange'
]
export default function parseBaseApp (vm, {