笨脑壳笔记一

  1. less中clac解析不正确

    div {
        height: calc(~"100% - 30px");
    }
    
  2. 隐藏input中的checkBox的默认样式

    input[type='checkbox'] {
        -webkit-appearance: none;
    }
  3. 把GWDTAssistant部署到公网遇到的问题

    1. 由于是静态页面,所以考虑用百度的BAE。用php可以直接路径匹配,node不熟悉所以没用。用php可以直接按照文件夹里的路径直接在地址栏打出即可。
    2. 然后build项目,直接npm run compile生成的html中引用的src都是10.1.50.30:3000开头,所以应该先修改路径的配置。通过尝试和查资料,是在webpack的publicPath配置:
    config.output = {
      filename   : `[name].[${project.compiler_hash_type}].js`,
      path       : project.paths.dist(),
      publicPath : project.compiler_public_path
    }

    project.compiler_public_path则是在config/environments.config.js里配置:

    module.exports = {
      development : (config) => ({
        compiler_public_path : `http://${config.server_host}:${config.server_port}/`
      }),
    
      // ======================================================
      // Overrides when NODE_ENV === 'production'
      // ======================================================
      production : (config) => ({
        // 这里配置
        compiler_public_path     : 'http://kangkai.duapp.com/gw/',
        compiler_fail_on_warning : false,
        compiler_hash_type       : 'chunkhash',
        compiler_devtool         : 'hidden-source-map',
        compiler_stats           : {
          chunks       : true,
          chunkModules : true,
          colors       : true
        }
      })
    }

    注意需要配置环境变量为生产export NODE.ENV='production'然后再npm run compile

    1. 当把编译后的文件放在bae的gw二级目录中(http://kangkai.duapp.com/gw),打开网站发现react-router并没有匹配成功,然后查资料发现是BrowserRouter的问题,继续查阅react-router4的文档,尝试添加basenamne='gw'然后发现成功。
    // The base URL for all locations. If your app is served from a  sub-directory on your server, you’ll want to set this to the sub-directory. A properly formatted basename should have a leading slash, but no trailing slash.
    
    <BrowserRouter basename="/calendar"/>
    <Link to="/today"/> // renders <a href="/calendar/today">
  4. react中在componentDidMount中拿不到某个元素的宽高

    // 问题代码
    componentDidMount () {
        const container = this.refs.arc
        const width = container.offsetWidth
        const height = container.offsetHeight
        console.log(width, height, container)
      }
    // 延迟
    componentDidMount () {
        const container = this.refs.arc
        setTimeout(function () {
          const width = container.offsetWidth
          const height = container.offsetHeight
          console.log(width, height, container)
        }, 300)
      }
  5. d3.json的问题

    d3.json('data.json', function () {...})

    d3.json是==rest请求==,所以路径是相对于URL的。而不是相对于某个js文件的路径。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值