我正在尝试构建一个小的3步形式.这将类似于:
我做出反应的方式是使用redux来跟踪表单完成并根据步骤编号(0,1,2)呈现表单正文标记.
在角度2中,这样做的好方法是什么?这就是我现在正在尝试的东西,而我还在努力.我的方法很好吗?有没有更好的方法呢?
我有一个父组件<app-form>,我会在其内部嵌套<app-form-header>和<app-form-body>.
<app-form>
<app-header [step]="step"></app-header>
<app-body [formData]="formData"></app-body>
</app-form>
Run Code Online (Sandbox Code Playgroud)
在<app-form>组件中我有一个step: number和formData: Array<FormData>.该步骤只是formData中每个对象的索引.这将传递给标题.formData将负责用户的表单数据.每次表单输入有效时,用户都可以单击"下一步"执行nextStep()以增加索引.每个步骤都有一个关联的模板标记.
有没有更好的方法来做这样的事情?
我想知道我为项目使用完整路径的最佳方法。
例如,如果我要导入组件,则我不想做import Component from '../components/Component',而只是想做import Component from 'app/components/Component';
有人可以帮我吗?
我正在查看一些代码,我看到它的编写如下所示.这对我来说没有意义.这是错的吗?为什么这样写?此外,不应该use strict;在代码之外的最顶端?
(function() {
'use strict';
angular.module('itemList', [])
.component('itemList', {
templateUrl: 'item-list/item-list.component.html',
controller: ['Item', ItemController]
});
function ItemController(Item) {
//code
}
}());
Run Code Online (Sandbox Code Playgroud) 我有一个组件,我在其中导入reactBootstrap:
import ReactBootstrap from 'react-bootstrap'
Run Code Online (Sandbox Code Playgroud)
然后我在我的组件中有一个函数,当用户单击按钮时会触发该函数:
onClickBtn : function() {
var Modal = ReactBootstrap.Modal;
return (
<Modal>
...
</Modal>
)
}
Run Code Online (Sandbox Code Playgroud)
但是,我收到错误:
未捕获的TypeError:无法读取未定义的属性"模态".
我在使用react-bootstrap指南时遇到了麻烦,我想知道是否有人知道如何轻松导入模态.谢谢
对不起,如果这是一个愚蠢的问题,但我是新手,并试图了解.
我的节点服务器在localhost:9000上运行,我正在尝试使用webview.这是我想要回归的 -
<View style={[styles.container]}>
<WebView
ref={'webview'}
automaticallyAdjustContentInsets={false}
style={styles.webView}
source={{uri: 'http://localhost:9000/login'}}
javaScriptEnabled={true}
onNavigationStateChange={this.onNavigationStateChange.bind(this)}
startInLoadingState={true}
scalesPageToFit={true}
/>
</View>
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用,因为我收到以下错误:
Encountered an error loading page Object {canGoForward: false, code: -6, canGoBack: false, description: "net::ERR_CONNECTION_REFUSED", loading: false…}canGoBack: falsecanGoForward: falsecode: -6description: "net::ERR_CONNECTION_REFUSED"loading: falsetarget: 9title: ""url: "http://localhost:9000/login"__proto__: ObjectreactConsoleError @ ExceptionsManager.js:76console.error @ YellowBox.js:48onLoadingError @ WebView.android.js:300proxiedMethod @ createPrototypeProxy.js:44invokeGuardedCallback @ ReactErrorUtils.js:26executeDispatch @ EventPluginUtils.js:87executeDispatchesInOrder @ EventPluginUtils.js:110executeDispatchesAndRelease @ EventPluginHub.js:42executeDispatchesAndReleaseTopLevel @ EventPluginHub.js:53forEachAccumulated @ forEachAccumulated.js:26processEventQueue @ EventPluginHub.js:215runEventQueueInBatch @ ReactEventEmitterMixin.js:18handleTopLevel @ ReactEventEmitterMixin.js:29(anonymous function) @ ReactNativeEventEmitter.js:122perform @ Transaction.js:136batchedUpdates @ ReactDefaultBatchingStrategy.js:63batchedUpdates @ ReactUpdates.js:97_receiveRootNodeIDEvent @ ReactNativeEventEmitter.js:121receiveEvent …
javascript ×3
react-native ×2
android ×1
angular ×1
angularjs ×1
forms ×1
node.js ×1
reactjs ×1
webview ×1