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

使用小程序原生wxss,@import引入的文件中的px不会转化为rpx #746

Closed
Ariskywi opened this issue Sep 29, 2018 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@Ariskywi
Copy link

Ariskywi commented Sep 29, 2018

问题描述
taro首次启动时,譬如npm run dev:weapp,a.wxss文件 中@import 的 b.wxss文件中的px,不会被转为rpx。只有修改再保存后才会转化。

复现步骤
1、page/路径下新建页面details.js、details.wxss、details.wxml、details.json

details.js

const app = getApp()
Page({
  data: {},
  customData: {},
  onLoad: function () {},
  onReady: function () {}
})

details.wxml

<import src="../../templates/test.wxml" />
<view class='details'>
  <template is="list" ></template>
</view>

details.wxss

@import "../../templates/test.wxss";

details.json

{
  "navigationBarBackgroundColor": "#ffffff",
  "navigationBarTextStyle": "black",
  "navigationBarTitleText": "详情",
  "backgroundColor": "#eeeeee",
  "backgroundTextStyle": "light"
}

2、src/templates/下新建test.wxml和test.wxss

test.wxml

<template name="list">
    <text class="boldFont">这是一段测试文本</text>
</template>

test.wxss

.boldFont{
  font-weight: bold;
  font-size: 36px;
}

3、app.js中配置

pages: [
      'pages/details/details',
      'pages/index/index'
    ],

4、config/index.js增加配置

copy: {
    patterns: [
      { from: 'src/templates/', to: 'dist/templates/' },
    ]
  },

5、启动应用 npm run dev:weapp

6、小程序查看font-size为36px

期望行为
test.wxss中的px转为rpx

报错信息

无报错。

系统信息

  • 操作系统: windows 7
  • Taro 版本 1.0.5
  • Node.js 版本 8.11.4
    -微信开发者工具版本: v1.02.1809260

补充信息
可修复的动作:
修改test.wxss中的任意内容,然后保存

.boldFont{
  font-weight: bold;
  font-size: 36px;
 width: 100%;
}

保存。页面正常转为rpx了。
复现: 结束 npm run dev:weapp,再次运行npm run dev:weapp,则可再次复现。

心塞 - -

@luckyadam luckyadam self-assigned this Sep 29, 2018
@luckyadam luckyadam added the bug Something isn't working label Sep 29, 2018
@Ariskywi
Copy link
Author

Ariskywi commented Oct 1, 2018

@luckyadam 请问这个问题下个版本会修复吗?

@luckyadam
Copy link
Member

@Ariskywi 会的,正在处理,目前可以通过在 js 中import 这个 wxss 文件来解决

@Ariskywi
Copy link
Author

Ariskywi commented Mar 4, 2019

@luckyadam

版本v1.2.15
此问题还在

补充说明:是每次重启 npm run dev:weapp,就不会转化了

每次重新打开环境样式就乱了。。求支持

@Ariskywi
Copy link
Author

Ariskywi commented Mar 4, 2019

@Ariskywi 会的,正在处理,目前可以通过在 js 中import 这个 wxss 文件来解决

js中import好像也不起作用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants