Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.1k views
in Technique[技术] by (71.8m points)

nextjs 引入scss后路由无法跳转

/src/pages/index.js

import Link from "next/link"

const Index = () => (
    <div>
        <Link href="/demo">jump</Link>
    </div>
)
export default Index

/src/pages/demo.js

import "../assets/scss/demo.scss"

const Demo = () => (
    <div className="bg-red">
        Demo page
    </div>
)
export default Demo

/src/assets/scss/demo.scss

.bg-red {
    background-color: #f00;
}

点链接jump后页面无法跳转,但终端有反应,注释import "...scss"后就可以跳转。

/next.config.js

const withSass = require('@zeit/next-sass')
module.exports = withSass()

package.json

{
  "dependencies": {
    "@zeit/next-sass": "^1.0.1",
    "next": "^10.0.1",
    "node-sass": "^4.14.1",
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  },
  "scripts": {
    "dev": "next",
    "build": "next build",
    "export": "next export"
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...