Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat support native to h5 #1410

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Feat support native to h5 #1410

wants to merge 22 commits into from

Conversation

Blackgan3
Copy link
Collaborator

功能

支持原生组件跨平台输出H5

待补充

  • 小程序原生组件中绑定事件使用动态绑定
  • 小程序import + template语法支持

})
},
methods: {
setData (data, callback) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

通过Vue.prototype来挂载

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移到VuePlugin.js当中

@@ -1621,6 +1623,14 @@ try {
})
}
}
if (queryObj.isNative && nativeLoaderIndex !== loaders.length - 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要考虑.ts的情况

if (mode === 'web') {
resource = `${resource}?isNative=true`
} else {
resource = `!!${nativeLoaderPath}!${resource}?isNative=true`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

统一在afterResolve中插入nativeLoader吧,这里统一加isNative Query就可以

@@ -201,6 +239,76 @@ module.exports = function (content) {
if (json.componentPlaceholder) {
componentPlaceholder = componentPlaceholder.concat(Object.values(json.componentPlaceholder))
}

if (mode === 'web') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块不会是copy的吧,抽一个通用逻辑呗

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vueContentCache的逻辑补齐

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainScript逻辑补齐

@@ -140,6 +148,36 @@ module.exports = function (content) {
})
}, callback)
},
(callback) => {
if (mode === 'web') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只有template和json需要预读,且文件的支持类型需要保持一致

@@ -7,7 +7,8 @@ module.exports = function (content) {
this.cacheable()
// 兼容处理处理ts-loader中watch-run/updateFile逻辑,直接跳过当前loader及后续的loader返回内容
const pathExtname = path.extname(this.resourcePath)
if (!['.vue', '.mpx'].includes(pathExtname)) {
const { queryObj } = parseRequest(this.resource)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块不可能经过selector的

return
}
Object.keys(data).forEach(key => {
this[key] = data[key]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要支持路径设置

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要调用forceUpdate

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要考虑key不在原有data中的情况

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants