Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_68066342
uni-app
提交
286e26a0
U
uni-app
项目概览
m0_68066342
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
286e26a0
编写于
7月 14, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 小程序端解构组件样式兼容不同平台
上级
4f756ad0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
15 deletion
+22
-15
packages/uni-mp-weixin/lib/uni.compiler.js
packages/uni-mp-weixin/lib/uni.compiler.js
+10
-5
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
...es/webpack-uni-mp-loader/lib/plugin/generate-component.js
+12
-10
未找到文件。
packages/uni-mp-weixin/lib/uni.compiler.js
浏览文件 @
286e26a0
...
...
@@ -12,9 +12,9 @@ wx.createComponent({
`
}
function
generateCssCode
(
ownerN
ame
)
{
function
generateCssCode
(
filen
ame
)
{
return
`
@import
'./
${
ownerName
}
.wxss'
@import
"./
${
filename
}
"
`
}
...
...
@@ -106,10 +106,15 @@ module.exports = {
const
jsContent
=
generateJsCode
(
genCode
(
t
.
objectExpression
(
objectProperties
),
true
))
state
.
files
[
jsFile
]
=
jsContent
const
cssFile
=
resourcePath
.
replace
(
ownerName
+
extname
,
componentName
+
'
.wxss
'
)
const
cssContent
=
generateCssCode
(
ownerName
)
try
{
// TODO 使用 getPlatformExts 在单元测试报错,改从 state.options.platform 判断
const
{
getPlatformExts
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
let
styleExtname
=
getPlatformExts
().
style
const
styleFile
=
resourcePath
.
replace
(
ownerName
+
extname
,
componentName
+
styleExtname
)
const
styleContent
=
generateCssCode
(
ownerName
+
styleExtname
)
state
.
files
[
cssFile
]
=
cssContent
state
.
files
[
styleFile
]
=
styleContent
}
catch
(
error
)
{}
if
(
!
state
.
generic
)
{
state
.
generic
=
[]
...
...
packages/webpack-uni-mp-loader/lib/plugin/generate-component.js
浏览文件 @
286e26a0
...
...
@@ -2,7 +2,8 @@ const fs = require('fs')
const
path
=
require
(
'
path
'
)
const
{
removeExt
,
normalizePath
normalizePath
,
getPlatformExts
}
=
require
(
'
@dcloudio/uni-cli-shared
'
)
const
{
getComponentSet
...
...
@@ -64,7 +65,7 @@ module.exports = function generateComponent (compilation) {
const
concatenatedModules
=
modules
.
filter
(
module
=>
module
.
modules
)
const
uniModuleId
=
modules
.
find
(
module
=>
module
.
resource
&&
normalizePath
(
module
.
resource
)
===
uniPath
).
id
const
wxss
Imports
=
{}
const
style
Imports
=
{}
Object
.
keys
(
assets
).
forEach
(
name
=>
{
if
(
components
.
has
(
name
.
replace
(
'
.js
'
,
''
)))
{
...
...
@@ -126,20 +127,21 @@ module.exports = function generateComponent (compilation) {
assets
[
name
].
source
=
newSource
}
}
if
(
name
.
endsWith
(
'
.wxss
'
))
{
const
styleExtname
=
getPlatformExts
().
style
if
(
name
.
endsWith
(
styleExtname
))
{
// 移除部分含有错误引用的 wxss 文件
let
origSource
=
assets
[
name
].
source
()
origSource
=
origSource
.
trim
?
origSource
.
trim
()
:
''
const
result
=
origSource
.
match
(
/^@import
[
"'
](
.+
?)[
"'
]
$/
)
if
(
result
)
{
const
wxss
Path
=
path
.
join
(
path
.
dirname
(
name
),
result
[
1
])
if
(
Object
.
keys
(
assets
).
includes
(
wxss
Path
))
{
wxssImports
[
wxssPath
]
=
wxssImports
[
wxss
Path
]
||
[]
wxssImports
[
wxss
Path
].
push
(
name
)
const
style
Path
=
path
.
join
(
path
.
dirname
(
name
),
result
[
1
])
if
(
Object
.
keys
(
assets
).
includes
(
style
Path
))
{
styleImports
[
stylePath
]
=
styleImports
[
style
Path
]
||
[]
styleImports
[
style
Path
].
push
(
name
)
}
else
{
if
(
wxss
Imports
[
name
])
{
wxss
Imports
[
name
].
forEach
(
name
=>
delete
assets
[
name
])
delete
wxss
Imports
[
name
]
if
(
style
Imports
[
name
])
{
style
Imports
[
name
].
forEach
(
name
=>
delete
assets
[
name
])
delete
style
Imports
[
name
]
}
delete
assets
[
name
]
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录