开发者问题收集
当我使用此代码从 url 路径获取 id(http://127.0.0.1:8083/#/zhuolian/activity/detail/1)时:import { useParams } from "react-router-dom";handleSearchInfo = () => {const {id} = useParams();const { dispatch } = this.prop
我是 javascript 和 React 的新手。我开始从事该项目https://github.com/udacity/reactnd-project-myreads-starter,当我在索引文件中写入此内容时import React from "react";import ReactDOM from "react-dom";import App from "./App";import "./
我需要在 2 条路径之间路由,我安装了npm install react-router(react-router: 6.2.1 和 react-router-dom: 5.2.0)。我在网页中收到一条错误消息Error: useRoutes() may be used only in the context of a <Router> component.,这最终意味着我没有使用 BrowserR
我在生产中的 React 应用程序中收到此错误:TypeError:无法读取 null 的属性(读取“useRef”)启用 sourcemap 后,它会在react.production.min.js中显示错误>奇怪的是,我只在特定路由上收到此错误。所有其他路由都运行良好(即使我在多个文件中使用了useRef)。由于本地构建运行良好,我无法在本地重现该问题。我尝试了以下操作:恢复到之前的工作提交。
我在我的 React 应用中使用react-router-dom。当我使用:function App() {return (<BrowserRouter>{ useRoutes(routes) }</BrowserRouter>);}并且我收到错误消息:未捕获错误:useRoutes() 只能在 <Router> 组件的上下文中使用。我搜索了如何修复它并将我的代码结构更改为:function Ap
我用 Alpine JS 创建了一个简单的倒计时,但是当计时器为 0 时,出现了错误。首先在 x-data 中声明函数 appTimer。 <div x-data="appTimer()"><div x-show="active"><template x-if="countdown > 0"><div><div>Counting down</div><div x-text="countdown">
嗨,我试图让 Alpine 和 webpack 一起运行,但总是出错,不知道该怎么做。我的 Webpack 配置:const path = require('path');const MiniCssExtractPlugin = require('mini-css-extract-plugin');const isProduction = 'prod
我尝试在下拉菜单的更改事件中更新x-data“tab”,使用选择选项中的值,但变量为“未定义”。<div class="py-0 space-y-6 bg-white" **x-data**="{ tab: 'payment_methods' }"><div class="py-6 mb-4 md:px-14 sm:px-14 px-4"><!-- Tabs --><div class="lg:h
嗨,我正在使用 alpine 的 CDN 链接:“https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.9.0/cdn.min.js”我这样做了👇在实时服务器中,我在控制台中收到此错误:检查屏幕截图是否有错误请告诉我问题是什么。Uncaught TypeError: Cannot read properties of undefined (readin
我正在使用 Laravel 的 Blade 语法构建表单,并使用 AlpineJs 进行一些交互,例如显示和隐藏内容。我的代码在这里:<div class="flex items-center" x-data="destinationBuilder"><x-label required="true" class="mr-5">Destination:</x-label><x-basic-input
我有一个 Django 模板,其中包含 Alpine.js (v3.10.2) 的脚本标记:<div x-data="product" class="product">...</div><script>document.addEventListener('alpine:init', () => {Alpine.data('product', () => ({count: 1,increment()
然而,我使用 alpine js 创建了一个小部件,出现了类似错误,我找到了解决方案。您认为我的代码中有什么错误?当我提取数据时,标题部分显示不正确。但我看不出有什么问题。或者我无法弄清楚。[我在控制台中看到的错误][1][1]: https://i.sstatic.net/ofmW1.png<div class="text-base w-56 px-5 rounded-full overflow
使用 AlpineJS 我有代码: <form x-data="inquiry()" x-on:submit.prevent="submit" method="post"><div><label>Name</label><input type="text" name="name" x-model="data.name.value"></div><div><label>Email</label><
按照安装说明操作后,alpinejs 无法正常工作。我按照Codechef中的说明安装 alpine。我像这样在 blade.php 中使用它: <script src="{{ asset('js/alpine.js') }}"></script><!-- other elements ommitted for brevity --><div x-data=""{ show: false}><bu
尝试从react-router-dom导入useNavigate时,出现以下错误:Attempted import error: 'useNavigate' is not exported from 'react-router-dom'.我的导入语句:import { useNavigate } from 'react-router-dom';