问答详情
源自:4-1 组件框架搭建

class为undefined

http://img3.mukewang.com/5f2390d40001dada03530110.jpg

 let styles = require('./popup.css')
 ...
 this.tempContainer.innerHTML = `<h1 class=${styles.popup}> Hello world </h1>`
{        test: /\.css$/,        use: [          'style-loader',          {            loader: "css-loader",            options: {              modules: {                localIdentName: '[path][name]__[local]--[hash:base64:5]'              }            }          }        ],        include: [          path.resolve(__dirname, '/src/components')        ]      },


提问者:Dreamer1017 2020-07-31 11:34

个回答

  • qq_慕UI4238351
    2022-10-28 16:30:13

    http://img2.mukewang.com/635b92080001dfd306620172.jpg

    可以通过控制台打印styles看到popup在default中,然后通过下面的方式解决了问题

    http://img1.mukewang.com/635b929f00013a5310990032.jpg

  • Dreamer1017
    2020-07-31 13:51:33

    http://img1.mukewang.com/5f23b12c0001dfe206310479.jpg

    解决了,应该写成‘src/components’,而不是‘/src/components’