每次运行时我都会遇到错误npm run build
错误:
/node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/validate.js:66
const ajv = new Ajv({
^
TypeError: Ajv is not a constructor
at Object.<anonymous> (/home/ts34mpr/website/client/node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/validate.js:66:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/ts34mpr/website/client/node_modules/mini-css-extract-plugin/node_modules/schema-utils/dist/index.js:6:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
Run Code Online (Sandbox Code Playgroud)
请问有人知道解决办法或者可以帮忙吗!谢谢
如果 LoggedIn 和 admin 为 true,同时将道具发送到 /admin,我正在尝试导航到管理页面,但这不起作用。你能帮忙吗?
export default function Auth() {
function login(e) {
e.preventDefault();
const data = { email, password };
axios
.post("http://localhost:3001/api/Login", data, { withCredentials: true })
.then((response) => {
if(!!response.data.loggedIn && !!response.data.admin){ return( <Navigate to="/admin" loggedIn={"response.data.loggedIn"} replace/> )}
else if(!!response.data.loggedIn && ! !!response.data.admin){ window.location.href = "https://www.dummyweb.com/webmail";}
else{return(alert("Username or Password is not valid!"))}
});
}
return (
<div>
<LogginForm/>
</div>
)
}
Run Code Online (Sandbox Code Playgroud) 我正在使用react-leaflet,并添加了一个带有事件处理程序的标记,单击即可缩放到该标记,但是当我尝试使用 const map=useMap() 时,我得到的只是这个错误=>:
Uncaught Error: No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>
Run Code Online (Sandbox Code Playgroud)
可能有类似的问题但没有答案,有人可以帮忙解决吗?这是我的代码:
const map = useMap()
return (
<div>
<MapContainer
className="leaflet-container"
center={[33.8735578, 35.86379]}
zoom={9}>
<TileLayer
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<Marker
icon={port}
eventHandlers={{
click: (e) => {
map.setView(e.latlng, 14);
},
}}
position={[33.90757548098519, 35.51700873340635]}
></Marker>
</MapContainer>
Run Code Online (Sandbox Code Playgroud)
谢谢!
我试图获取鼠标在地图上单击的位置的坐标,但 .locate() 仅返回地图的中心坐标。有办法吗?附:我没有使用基于类的反应。谢谢
<MapContainer
center={[ 33.8735578, 35.86379]}
zoom={9}
scrollWheelZoom={true}
>
<TileLayer
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
</MapContainer>
Run Code Online (Sandbox Code Playgroud) javascript ×4
reactjs ×4
leaflet ×2
ajv ×1
build ×1
maps ×1
navigation ×1
npm ×1
react-router ×1
routes ×1