小编Fir*_*CMP的帖子

类型错误:当我运行 npm run build 时,Ajv 不是构造函数

每次运行时我都会遇到错误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)

请问有人知道解决办法或者可以帮忙吗!谢谢

javascript build npm reactjs ajv

8
推荐指数
1
解决办法
6765
查看次数

如何在三元运算符上导航反应页面?

如果 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)

javascript navigation routes reactjs react-router

6
推荐指数
2
解决办法
1362
查看次数

未捕获错误:未提供上下文:useLeafletContext() 只能在 &lt;MapContainer&gt; 的后代中使用

我正在使用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='&copy; <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)

谢谢!

javascript error-handling leaflet reactjs react-leaflet

5
推荐指数
1
解决办法
1万
查看次数

如何在leaflet React js中获取当前鼠标点击的坐标

我试图获取鼠标在地图上单击的位置的坐标,但 .locate() 仅返回地图的中心坐标。有办法吗?附:我没有使用基于类的反应。谢谢

 <MapContainer
          center={[ 33.8735578, 35.86379]}
        zoom={9}
        scrollWheelZoom={true}
  
      >
        <TileLayer
          attribution='&copy; <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 maps leaflet reactjs react-leaflet

0
推荐指数
1
解决办法
4309
查看次数