我该如何卸载纱线?我已经将它用于反应本机项目,现在每当我移出代码index.ios.js或者index.android.js它抛出错误所以我只想使用npm但是每当我初始化一个react-native项目时它默认为yarn.我试过npm uninstall yarn但是没用.谢谢.
我在React Native中遇到错误,说它无法解析模块.它说某个文件夹不存在,但路径不准确.它告诉我,Directory /Users/user/Desktop/RNApp/app/app/containers不存在.我不知道第二个应用程序来自哪条路径.我的目录看起来像这样
这就是我导出容器组件的方式 app/containers/index.js
export RNAppNavigator from './Navigator/RNAppNavigator'
export SplashContainer from './Splash/SplashContainer'
export AppContainer from './App/AppContainer'
Run Code Online (Sandbox Code Playgroud)
所以我应该能够像import {AppContainer} from '~/containers正确的那样导入它们吗?我没有遇到任何其他组件的问题.只是AppContainer.
谢谢!
有没有人遇到这个问题?我正在使用Vue Devtools,但无法检查任何组件,而没有出现。没有根组件或任何东西。几乎只是一个空白的DevTools。我是Vue的新手,所以我确定我缺少明显的东西。我正在使用webpack cli模板,尚未实现任何Vue Router东西。搜索组件时也没有任何反应。我假设这是这三个文件中的东西?
main.js
import Vue from 'vue'
import App from './App'
var db = firebase.database();
var vm = new Vue({
el: '#app',
created: function() {
// Import firebase data
var quizzesRef = db.ref('quizzes');
quizzesRef.on('value', function(snapshot) {
console.log(snapshot.val());
vm.quizzes = snapshot.val();
});
},
data: function() {
return {
authenticated: false,
quizzes: {},
resources: []
}
},
template: '<App/>',
components: { App }
})
Run Code Online (Sandbox Code Playgroud)
应用程序
<template>
<div id="app">
<navbar></navbar>
<resource-info></resource-info>
</div>
</template>
<script>
import Navbar from './components/Navbar'
import ResourceInfo from …Run Code Online (Sandbox Code Playgroud) 我环顾四周,如果导入或导出不正确,大多数问题都是结果,但我已经检查了我的应用程序,我不确定我导出/导入的错误.这是我得到的确切错误.
React.createElement:type无效 - 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object.您可能忘记从其定义的文件中导出组件.检查渲染方法
FooterTabs.
不确定render方法的含义.该组件没有render方法.无论如何...
所以FooterTabs我只是渲染一些页脚选项卡
import React, { PropTypes } from 'react'
import { View, Text } from 'react-native'
import { Tabs, Tab, Icon } from 'react-native-elements'
import { HomeContainer, TrackLibraryContainer } from '~/containers'
import { NimbusCamera } from '~/components'
export default function FooterTabs (props) {
console.log(props)
FooterTabs.propTypes = {
navigator: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired,
activeFooterTab: PropTypes.string.isRequired,
setFooterTab: PropTypes.func.isRequired,
}
return (
<Tabs>
<Tab
selected={props.activeFooterTab === "home"}
titleStyle={{fontWeight: 'bold', fontSize: 10}}
selectedTitleStyle={{marginTop: -1, marginBottom: 6}}
title="Home" …Run Code Online (Sandbox Code Playgroud) 我的组件状态有两个图像路径
我尝试上传一个函数内的一个图像,但得到一个错误:
Firebase Storage: Invalid argument in 'put' at index 0: Expected Blob or file
Run Code Online (Sandbox Code Playgroud)
和我的功能
submitImages = () => {
// Upload images to Firebase storage
let user = firebaseAuth.currentUser;
let imagesRef = storageRef.child('productImages/' + user.uid);
imagesRef.put(this.state.imageFront).then(snapshot => {
console.log('Uploaded ' + this.state.imageFront);
});
}
Run Code Online (Sandbox Code Playgroud)
我应该做些什么来将这些图像传输到Firebase.谢谢!
我有一个使用Apollo钩子库的useQuery钩子的React组件。我在测试此组件时遇到问题。这是我当前的设置。
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import DashboardBar from './DashboardBar';
import { render, cleanup } from '@testing-library/react';
import { QUERY } from '../../queries';
import { ApolloClient } from 'apollo-client';
import { ApolloProvider as ApolloHooksProvider } from '@apollo/react-hooks';
import { MockedProvider } from 'react-apollo/test-utils';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { MockLink } from 'apollo-link-mock';
import wait from 'waait';
import casual from 'casual';
describe('<DashboardBar />', () => {
it('renders and matches …Run Code Online (Sandbox Code Playgroud) javascript reactjs react-apollo react-hooks react-apollo-hooks
刚刚开始使用样式化组件。有没有办法设置第三方图标(例如“材料设计图标”)的样式?这是我到目前为止的代码,但显然无法正常工作。相对代码位于内容组件下方,谢谢!
const MaterialIcon = (props) => <i className="material-icons">account_balance</i>;
const Icon = styled(MaterialIcon)`
background-color: green;
font-size: 50px;
`;
const CheckThisOut = props => (
<Wrapper>
<Header>
<h5>{props.title}</h5>
<Icon />
</Header>
<Divider />
<Content>
<p>5% of all participants in this campaign were first time users.</p>
</Content>
</Wrapper>
);
export default CheckThisOut;
Run Code Online (Sandbox Code Playgroud)
我试图隐藏主应用程序导航栏,基于路径是否在给定路径上.
在我的App.vue组件中,在created()方法中.我确实检查路线是否为x || y,如果其中任何一个为真,我将我的Vuex状态设置show为false.如果是除了那两个之外的任何其他路线,我设置show = true.
然后在我的模板中我这样做
<template>
<div id="app">
<navigation v-show="show"></navigation>
<router-view></router-view>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我在Vuex工具中注意到我的突变甚至没有注册,所以我不确定为什么会这样.他们需要采取行动吗?这是我的完整代码.
<template>
<div id="app">
<navigation v-show="show"></navigation>
<router-view></router-view>
</div>
</template>
<script>
import Navigation from './components/Navigation/Navigation'
import { firebaseAuth } from './firebase/constants'
import store from './store/index'
export default {
name: 'app',
components: {
Navigation
},
computed: {
show () {
return store.state.navigation.show
}
},
created() {
// Checks for a user and dispatches an action changing isAuthed state to true.
firebaseAuth.onAuthStateChanged(user …Run Code Online (Sandbox Code Playgroud) 尝试设置Vue路由器。不知道我在做什么错。得到错误
Failed to mount component: template or render function not defined. (found in root instance)
再说一次,我是从React来到Vue的,虽然它们很相似,但是有些小东西却有所不同,而且Vue资源还不多。
我正在使用Webpack模板并使用单个文件组件。我不完全了解的一件事是文档中的这一部分
// 1. Define route components.
// These can be imported from other files
const Foo = { template: '<div>foo</div>' }
const Bar = { template: '<div>bar</div>' }
Run Code Online (Sandbox Code Playgroud)
他和我一样import Foo from 'path/to/component/吗?
无论如何,感谢您的所有帮助!
这是我的main.js档案
import Vue from 'vue'
import App from './App'
import QuizBuilder from '../src/components/QuizBuilder.vue'
import ResourceInfo from '../src/components/ResourceInfo.vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
{ …Run Code Online (Sandbox Code Playgroud) 来自React的Vue.在大多数情况下有很多相似之处,但传球props似乎有点不同.我找不到很多关于如何使用单个文件组件执行此操作的文档.我导入了应用程序的所有数据main.js.我想知道如何获取部分数据currentUser,例如,ResourceInfo.vue?再假设这些都是单个文件组件.我是否需要通过模板选项<App/>下的部分传递它,然后以某种方式进入?我也不想学习Vuex,因为我刚开始学习.谢谢!main.js<resource-info></resource-info>App.vueResourceInfo.vue
main.js
import Vue from 'vue'
import App from './App'
import ResourceInfo from '../src/components/ResourceInfo'
var db = firebase.database();
var auth = firebase.auth();
/* eslint-disable no-new */
var vm = new Vue({
el: '#app',
data: function() {
return {
users: {},
currentUser: {},
quizzes: {},
resources: []
}
},
template: '<App/>',
components: { App, ResourceInfo },
})
Run Code Online (Sandbox Code Playgroud)
App.vue
<template>
<div id="app">
<navbar></navbar>
<resource-info></resource-info>
</div>
</template>
<script>
import …Run Code Online (Sandbox Code Playgroud) vue.js ×4
javascript ×3
react-native ×3
reactjs ×2
firebase ×1
node.js ×1
react-apollo ×1
react-hooks ×1
vue-router ×1
yarnpkg ×1