我正在尝试重构具有硬编码初始状态的简单代码,但我对 React Hooks 还不熟悉。const TimersDashboard = () => {const [timers, timersChange] = useState(0)React.state = {timers: [{id: UUID.v4(),activity: 'Testing activity',description: 'Lo
2021-09-17
我尝试将数据从父组件传递到子组件。但是,我尝试传递的数据在子组件中一直打印为空白。我的代码:在Profile.js(父组件)中<template><div class="container"><profile-form :user ="user"></profile-form></div></template><script>import ProfileForm from './ProfileFo
2016-08-29
我有一个布局文件,里面有一些数据。除此之外,我还有三个组件:标签学生操作我想在布局文件中声明数据,但通过三个子组件访问它。如何在 Vue.js 中做到这一点?感谢您的帮助。
2017-01-25
我误解了将子组件传递给其他子组件的文档。我有两个组件index.html<main-categories-products source="{{ url('api/products') }}"></main-categories-products><sidebar-options> </sidebar-options>我的 app.js var app = new Vue({el: '#app',
2017-05-05
我正在练习 Vue JS,想了解如何将数据从子组件传递到发出事件的父组件。这是我的父组件 BookList:<template><div class="booklist"><BookForm @book-is-created="onClickForm" /><table v-for="book in books"><tr><th> Author </th><th> Title </th><th>
2017-05-20
我有一个组件contacts-list的子组件contactView,它本身也是一个子组件。问题是我无法动态更改此组件的内容html<div id="wrapper"><component :is="currentView" keep-alive></component></div>jsvar IndexPage = Vue.component('index-page', {template: '
2017-06-26
我是 vue.js 的新手,我尝试将一个值传递给子组件。HTML<div id="example"><my-component v-bind:data="parentData"></my-component></div>JSVue.component('my-component', {props: ['data'],template: '<div>Parent component with dat
2017-11-16
我有一个router-link,用于导航到我的一个组件。它还传递一个参数,然后在我的组件中设置该参数created() {this.sentData = this.$route.params.sentData;}当我导航到该页面时,我可以打印出已发送的数据,还可以看到它是在我的 Vue 控制台中设置的。所以这一切都很好。在此页面上,我使用的是vue-simple-uploader。只是一个非常简单
2019-01-19
我有一个vue组件,即page.vue。我有一个card card的孩子vue组件。尝试在内部注入数据在页面组件的数据功能中。page.vue522039861card.vue0096344432<< p>我希望该卡还可以从其他组件中重新使用。需要将数据注入到显示位置的卡中。
2019-02-19
我正在使用 Vue.js 和 Laravel 创建一个纸牌游戏。我想使用 Vue.js 将remaining_cards的值从父级 (Card.vue) 传递给子级 (Footer.vue)。因此,当remaining cards的值更新时,即使页脚中显示的值也会更新。Card.vue:<template><div><app-header></app-header><div class="row
2020-04-22
我如何将图像 URL 传递给此 Vue 组件?我将代码移动到一个单独的 php 文件中,该文件将保存 Vue 使用的<script>标记,但它无法识别从父组件传递的数据。Vue.component('theme-parallax',{template: '#parallax-tpl',data(){return{pageData: []}}});组件标记NB:page.embedded.paral
2020-04-23
我正在本地主机上设置 NextJS 应用,并按照网站上的精彩教程进行操作,但是在插入本地 API 时遇到了问题。更改 JS 代码时出现错误。错误是 TypeError: Cannot read property 'id' of undefined(anonymous function)/Users/mattcohen/hello-next/.next/server/static/developm
我正在使用 Nextjs 并尝试上传单个文件。每次我附加新文件时,控制台日志中都会出现此错误。在控制台中,我看到此错误:Warning: A component is changing an uncontrolled input of type file to be controlled. Input elements should not switch from uncontrolled to
我正在使用 Nextjs 创建注释组件以进行服务器端渲染。在开发模式下,一切正常,但是当我尝试构建优化的生产时,next js 会抱怨Cannot read property 'byname' of undefined这是我的组件:import React from 'react'import moment from 'moment-timezone'export default function
2020-06-11
我正在尝试使用 React 上下文和多步骤表单创建一个简单的测验应用。这是我处理表单数据的代码import { useState, createContext, useContext } from "react";export const QuizContext = createContext();export default function QuizProvider({ children })