Git Product home page Git Product logo

Comments (4)

suwu150 avatar suwu150 commented on September 7, 2024

请问这种还有其它方式进行更改样式吗

from antd-mobile-samples.

suwu150 avatar suwu150 commented on September 7, 2024

覆盖成功了,将antd-mobile-rn修改成antd-mobile,因为我的版本是2.1.8,在node_modules中还是antd-mobile形式的

const path = require('path');
const fs = require('fs');
// for 1.x
// const defaultVars = require('antd-mobile/lib/style/themes/default');
// for 2.x
const defaultVars = require('antd-mobile/lib/style/themes/default.native');
const customVars = require('../theme');
// for 1.x
// const themePath = path.resolve(require.resolve('antd-mobile'), '../style/themes/default.js');
// for 2.x
const themePath = path.resolve(require.resolve('antd-mobile'), '../style/themes/default.native.js');
const themeVars = Object.assign({}, defaultVars, customVars);

if (fs.statSync(themePath).isFile()) {
  fs.writeFileSync(
    themePath,
    'var brandPrimary = "#108ee9"; var brandPrimaryTap = "#1284d6";module.exports = ' + JSON.stringify(themeVars)
  );
}

我理解了一下,这种覆盖之后,你自己自定义的样式就是默认的样式,官方的样式已经不存在了,也就是说要想再次使用官方样式,你就得删掉node_modules并且重新install

from antd-mobile-samples.

warmhug avatar warmhug commented on September 7, 2024

看这里 Object.assign({}, defaultVars, customVars) 只是覆盖你自己设置的同名样式,其他不覆盖

from antd-mobile-samples.

suwu150 avatar suwu150 commented on September 7, 2024

version: "antd-mobile": "^2.1.8",
我重新install之后,

const defaultVars = require('antd-mobile/lib/style/themes/default.native');

default.native中的default.native不见了,我修改为default.less之后,报这样的错误

/Users/jkwu/WebStormProject/FLS_MW_APP/node_modules/antd-mobile/lib/style/themes/default.less:1
(function (exports, require, module, __filename, __dirname) { @hd: 1px; // 基本单位
                                                              ^

SyntaxError: Invalid or unexpected token
    at createScript (vm.js:74:10)

from antd-mobile-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.