diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js index 1bf747541f8e5e0ffe75b6c8ee30b5e674f9f922..b852d120c00caf44e8896da2c910f0343ba68871 100644 --- a/packages/uni-app-plus/dist/index.js +++ b/packages/uni-app-plus/dist/index.js @@ -366,9 +366,33 @@ function createObserver (name) { } } -function getProperties (props) { - const properties = { - vueSlots: { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots +function getBehaviors (vueExtends, vueMixins) { + const behaviors = []; + if (isPlainObject(vueExtends) && vueExtends.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueExtends.props, true) + }) + ); + } + if (Array.isArray(vueMixins)) { + vueMixins.forEach(vueMixin => { + if (isPlainObject(vueMixin) && vueMixin.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueMixin.props, true) + }) + ); + } + }); + } + return behaviors +} + +function getProperties (props, isBehavior = false) { + const properties = {}; + if (!isBehavior) { + properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots type: null, value: [], observer: function (newVal, oldVal) { @@ -380,8 +404,8 @@ function getProperties (props) { $slots }); } - } - }; + }; + } if (Array.isArray(props)) { // ['title'] props.forEach(key => { properties[key] = { @@ -849,6 +873,8 @@ function createComponent (vueOptions) { const properties = getProperties(vueOptions.props); + const behaviors = getBehaviors(vueOptions['extends'], vueOptions['mixins']); + const VueComponent = Vue.extend(vueOptions); const componentOptions = { @@ -857,6 +883,7 @@ function createComponent (vueOptions) { addGlobalClass: true }, data: getData(vueOptions, Vue.prototype), + behaviors, properties, lifetimes: { attached () { diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index b1df8791de444e89c998fcaecdb777bc86494d30..9389486e0b2c2b8be9c3e4c1b5a98373f2305e66 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-app-plus", - "version": "0.0.220", + "version": "0.0.221", "description": "uni-app app-plus", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js index bff99602ac86d8a28f63642c733536e9ebc1a2c2..297eae966cad8240b6d11586b066c1597490b267 100644 --- a/packages/uni-mp-baidu/dist/index.js +++ b/packages/uni-mp-baidu/dist/index.js @@ -501,9 +501,33 @@ function createObserver (name) { } } -function getProperties (props) { - const properties = { - vueSlots: { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots +function getBehaviors (vueExtends, vueMixins) { + const behaviors = []; + if (isPlainObject(vueExtends) && vueExtends.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueExtends.props, true) + }) + ); + } + if (Array.isArray(vueMixins)) { + vueMixins.forEach(vueMixin => { + if (isPlainObject(vueMixin) && vueMixin.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueMixin.props, true) + }) + ); + } + }); + } + return behaviors +} + +function getProperties (props, isBehavior = false) { + const properties = {}; + if (!isBehavior) { + properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots type: null, value: [], observer: function (newVal, oldVal) { @@ -515,8 +539,8 @@ function getProperties (props) { $slots }); } - } - }; + }; + } if (Array.isArray(props)) { // ['title'] props.forEach(key => { properties[key] = { @@ -1016,6 +1040,8 @@ function createComponent (vueOptions) { const properties = getProperties(vueOptions.props); + const behaviors = getBehaviors(vueOptions['extends'], vueOptions['mixins']); + const VueComponent = Vue.extend(vueOptions); const componentOptions = { @@ -1024,6 +1050,7 @@ function createComponent (vueOptions) { addGlobalClass: true }, data: getData(vueOptions, Vue.prototype), + behaviors, properties, lifetimes: { attached () { diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index fcae15a74cedc65b6e0e27a79feb48859803930f..ebc76570daf0b709a9e12dcb92e1726ef52f03f5 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-baidu", - "version": "0.0.815", + "version": "0.0.816", "description": "uni-app mp-baidu", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index 6350ea38df74c4b53a6699f9b0d3d3ecdec16f4c..efe536a646248560cb9ba473f1785df065995e8e 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -546,9 +546,33 @@ function createObserver (name) { } } -function getProperties (props) { - const properties = { - vueSlots: { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots +function getBehaviors (vueExtends, vueMixins) { + const behaviors = []; + if (isPlainObject(vueExtends) && vueExtends.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueExtends.props, true) + }) + ); + } + if (Array.isArray(vueMixins)) { + vueMixins.forEach(vueMixin => { + if (isPlainObject(vueMixin) && vueMixin.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueMixin.props, true) + }) + ); + } + }); + } + return behaviors +} + +function getProperties (props, isBehavior = false) { + const properties = {}; + if (!isBehavior) { + properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots type: null, value: [], observer: function (newVal, oldVal) { @@ -560,8 +584,8 @@ function getProperties (props) { $slots }); } - } - }; + }; + } if (Array.isArray(props)) { // ['title'] props.forEach(key => { properties[key] = { @@ -1040,6 +1064,8 @@ function createComponent (vueOptions) { const properties = getProperties(vueOptions.props); + const behaviors = getBehaviors(vueOptions['extends'], vueOptions['mixins']); + const VueComponent = Vue.extend(vueOptions); const componentOptions = { @@ -1048,6 +1074,7 @@ function createComponent (vueOptions) { addGlobalClass: true }, data: getData(vueOptions, Vue.prototype), + behaviors, properties, lifetimes: { attached () { diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index cbf535f2fd9e2ed4467d0baa2e41e722718beafc..ca50ee5473ba20aee04dd11505541555e5bff36e 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-toutiao", - "version": "0.0.315", + "version": "0.0.316", "description": "uni-app mp-toutiao", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js index 9575a0e2911e6f3ba1e3b6b0f1ec10147255e9a9..b7d1642c2f3fad0a75ab51b6fc5f97698951ae35 100644 --- a/packages/uni-mp-weixin/dist/index.js +++ b/packages/uni-mp-weixin/dist/index.js @@ -393,9 +393,33 @@ function createObserver (name) { } } -function getProperties (props) { - const properties = { - vueSlots: { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots +function getBehaviors (vueExtends, vueMixins) { + const behaviors = []; + if (isPlainObject(vueExtends) && vueExtends.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueExtends.props, true) + }) + ); + } + if (Array.isArray(vueMixins)) { + vueMixins.forEach(vueMixin => { + if (isPlainObject(vueMixin) && vueMixin.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueMixin.props, true) + }) + ); + } + }); + } + return behaviors +} + +function getProperties (props, isBehavior = false) { + const properties = {}; + if (!isBehavior) { + properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots type: null, value: [], observer: function (newVal, oldVal) { @@ -407,8 +431,8 @@ function getProperties (props) { $slots }); } - } - }; + }; + } if (Array.isArray(props)) { // ['title'] props.forEach(key => { properties[key] = { @@ -869,6 +893,8 @@ function createComponent (vueOptions) { const properties = getProperties(vueOptions.props); + const behaviors = getBehaviors(vueOptions['extends'], vueOptions['mixins']); + const VueComponent = Vue.extend(vueOptions); const componentOptions = { @@ -877,6 +903,7 @@ function createComponent (vueOptions) { addGlobalClass: true }, data: getData(vueOptions, Vue.prototype), + behaviors, properties, lifetimes: { attached () { diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index c99796c5890b25ac7eb50605f67ebec4e1cb935f..2bea7672557aba28ef886946ba4997d46c19379b 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-mp-weixin", - "version": "0.0.939", + "version": "0.0.940", "description": "uni-app mp-weixin", "main": "dist/index.js", "scripts": { diff --git a/src/core/runtime/wrapper/create-component.js b/src/core/runtime/wrapper/create-component.js index e7ff868e6a4b709d1fac0875733ab699f72ace07..fb65f668dd0697b8812e5dc2c75a4138a2099608 100644 --- a/src/core/runtime/wrapper/create-component.js +++ b/src/core/runtime/wrapper/create-component.js @@ -9,6 +9,7 @@ import { import { getData, handleEvent, + getBehaviors, getProperties } from './util' @@ -44,6 +45,8 @@ export function createComponent (vueOptions) { const properties = getProperties(vueOptions.props) + const behaviors = getBehaviors(vueOptions['extends'], vueOptions['mixins']) + const VueComponent = Vue.extend(vueOptions) const componentOptions = { @@ -52,6 +55,7 @@ export function createComponent (vueOptions) { addGlobalClass: true }, data: getData(vueOptions, Vue.prototype), + behaviors, properties, lifetimes: { attached () { diff --git a/src/core/runtime/wrapper/util.js b/src/core/runtime/wrapper/util.js index 71316748bd543ae32e71d92d0cbd6260c4eb834e..e99d662586bec1a9ce0ffe6c1898a645a52ff893 100644 --- a/src/core/runtime/wrapper/util.js +++ b/src/core/runtime/wrapper/util.js @@ -62,9 +62,33 @@ function createObserver (name) { } } -export function getProperties (props) { - const properties = { - vueSlots: { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots +export function getBehaviors (vueExtends, vueMixins) { + const behaviors = [] + if (isPlainObject(vueExtends) && vueExtends.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueExtends.props, true) + }) + ) + } + if (Array.isArray(vueMixins)) { + vueMixins.forEach(vueMixin => { + if (isPlainObject(vueMixin) && vueMixin.props) { + behaviors.push( + Behavior({ + properties: getProperties(vueMixin.props, true) + }) + ) + } + }) + } + return behaviors +} + +export function getProperties (props, isBehavior = false) { + const properties = {} + if (!isBehavior) { + properties.vueSlots = { // 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots type: null, value: [], observer: function (newVal, oldVal) {