美文网首页
antd-mobile基本使用

antd-mobile基本使用

作者: zyghhhh | 来源:发表于2019-07-09 11:56 被阅读0次

    1 下包 npm install antd-mobile --save

    2 页面处理: index.html (官网上有)

     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-    scale=1, user-scalable=no" />
    <script src="https://as.alipayobjects.com/g/component/fastclick/1.0.6/fastclick.js"></script>
    <script>
    if ('addEventListener' in document) {
      document.addEventListener('DOMContentLoaded', function() {
        FastClick.attach(document.body);
      }, false);
    }
    if(!window.Promise) {
      document.writeln('<script src="https://as.alipayobjects.com/g/component/es6-promise/3.2.2/es6-promise.min.js"'+'>'+'<'+'/'+'script>');
    }
    </script>
    

    3 实现按需打包

       1 下包 npm install --save-dev babel-plugin-import react-app-rewired
    
       2 定义加载配置的js模块: config-overrides.js (在根目录下)
                const {injectBabelPlugin} = require('react-app-rewired');
                    module.exports = function override(config, env) {
                    config = injectBabelPlugin(['import', {libraryName: 'antd-mobile', style: 'css'}], config);
                    return config;
          }
    
       3 修改配置: package.json
           "scripts": {
                  "start": "react-app-rewired start",
                  "build": "react-app-rewired build",
                  "test": "react-app-rewired test --env=jsdom",
                  "eject": "react-scripts eject"
            }
    

    4 使用

    import {Button} from 'antd-mobile'

    相关文章

      网友评论

          本文标题:antd-mobile基本使用

          本文链接:https://www.haomeiwen.com/subject/rdfxkctx.html