Skip to content

Commit

Permalink
fix(uni-mp-xhs): fix the issue of useRef component being undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
hadi committed Aug 2, 2023
1 parent dfaa58d commit 79a5527
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 41 deletions.
47 changes: 22 additions & 25 deletions packages/uni-mp-xhs/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1938,15 +1938,10 @@ class EventChannel {

const eventChannels = {};

const eventChannelStack = [];

function getEventChannel (id) {
if (id) {
const eventChannel = eventChannels[id];
delete eventChannels[id];
return eventChannel
}
return eventChannelStack.shift()
const eventChannel = eventChannels[id];
delete eventChannels[id];
return eventChannel
}

const hooks = [
Expand Down Expand Up @@ -2254,36 +2249,38 @@ function parsePage (vuePageOptions) {
onLoad (query) {
const properties = this.props;

const options = {
this.__query = query;
this.__options = {
mpType: 'page',
mpInstance: this,
propsData: properties
};

},
onReady () {
// initChildVues(this)
// 初始化 vue 实例
this.$vm = new VueComponent(options);

initSpecialMethods(this);
this.$vm = new VueComponent(this.__options);

// 触发首次 setData
this.$vm.$mount();

const copyQuery = Object.assign({}, query);
delete copyQuery.__id__;
initSpecialMethods(this);
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted');

// mounted => onLoad
this.options = this.__query;
this.$vm.$mp.query = this.__query; // 兼容 mpvue
const copyQuery = Object.assign({}, this.__query);
delete copyQuery.__id__;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(copyQuery)
};

this.options = query;
this.$vm.$mp.query = query; // 兼容 mpvue
this.$vm.__call_hook('onLoad', query);
},
onReady () {
// initChildVues(this)
this.$vm._isMounted = true;
this.$vm.__call_hook('mounted');
this.$vm.__call_hook('onReady');
this.$vm.__call_hook('onLoad', this.__query);
setTimeout(() => {
this.$vm.__call_hook('onReady');
});
},
onUnload () {
this.$vm.__call_hook('onUnload');
Expand Down Expand Up @@ -2590,7 +2587,7 @@ if (typeof Proxy !== 'undefined' && "mp-xhs" !== 'app-plus') {
uni[name] = promisify(name, todoApis[name]);
});
Object.keys(extraApi).forEach(name => {
uni[name] = promisify(name, todoApis[name]);
uni[name] = promisify(name, extraApi[name]);
});
}

Expand Down
34 changes: 18 additions & 16 deletions src/platforms/mp-xhs/runtime/wrapper/page-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,38 @@ export default function parsePage (vuePageOptions) {
onLoad (query) {
const properties = this.props

const options = {
this.__query = query
this.__options = {
mpType: 'page',
mpInstance: this,
propsData: properties
}

},
onReady () {
// initChildVues(this)
// 初始化 vue 实例
this.$vm = new VueComponent(options)

initSpecialMethods(this)
this.$vm = new VueComponent(this.__options)

// 触发首次 setData
this.$vm.$mount()

const copyQuery = Object.assign({}, query)
delete copyQuery.__id__
initSpecialMethods(this)
this.$vm._isMounted = true
this.$vm.__call_hook('mounted')

// mounted => onLoad
this.options = this.__query
this.$vm.$mp.query = this.__query // 兼容 mpvue
const copyQuery = Object.assign({}, this.__query)
delete copyQuery.__id__
this.$page = {
fullPath: '/' + this.route + stringifyQuery(copyQuery)
}

this.options = query
this.$vm.$mp.query = query // 兼容 mpvue
this.$vm.__call_hook('onLoad', query)
},
onReady () {
// initChildVues(this)
this.$vm._isMounted = true
this.$vm.__call_hook('mounted')
this.$vm.__call_hook('onReady')
this.$vm.__call_hook('onLoad', this.__query)
setTimeout(() => {
this.$vm.__call_hook('onReady')
});
},
onUnload () {
this.$vm.__call_hook('onUnload')
Expand Down

0 comments on commit 79a5527

Please sign in to comment.