在这里,我正在做的是我正在使用
Yii::app()->SESSION['userid']
Run Code Online (Sandbox Code Playgroud)
没有
Yii::app()->session->open();
Run Code Online (Sandbox Code Playgroud)
在登录
Yii::app()->session->destroy();
Run Code Online (Sandbox Code Playgroud)
在注销时
我想知道如果不开放和破坏会话是值得的.Yii是否在内部进行.
还有一件奇怪的事我不知道发生了什么.在同一个会话的浏览器中,我可以登录多个用户..这不应该发生.这就是我没有使用open和destroy会话方法.
public function actionLogout()
{
Yii::app()->user->logout();
Yii::app()->session->clear();
$this->redirect(Yii::app()->controller->module->returnLogoutUrl);
}
Run Code Online (Sandbox Code Playgroud)
请让我知道如何解决这个问题
我正在定义 react 组件以与 redux 连接。我有应用程序和列表组件
应用程序.js
import React, { Component } from 'react';
//import Login from './components/Login';
import List from './components/List';
import './App.css';
class App extends Component {
render() {
return ( <List />); } }
export default App;
Run Code Online (Sandbox Code Playgroud)
列表.js
import React from 'react';
import { connect } from 'react-redux';
const mapStateToProps= state =>{
return { articles :state.articles};
}
const connectedList = ({ articles }) =>(
{articles.map(e=>( //////**1) here I get red under the dot(.) ie., error**
<li key={e.id}>{e.title}</li>
))} …
Run Code Online (Sandbox Code Playgroud) 我对React
这里的钩子不熟悉,我有一个侧边栏,我想将其更新为selecetedIndex
为此选择的索引,ListItem
即,当我选择一个项目时,我想更新selectedIdx
为索引以显示选定的索引。我做错了。
<ListItem button key={index}
selected={selectedIdx===index} // to show selected need to update
onclick={setSelectedIdx(index)}
>
<ListItemIcon>{v.icon}</ListItemIcon>
<ListItemText primary={v.text} />
</ListItem>
let [selectedIdx,setSelectedIdx]=React.useState(0);
Run Code Online (Sandbox Code Playgroud)
这样我第二次尝试但没有结果:
<ListItem button key={index}
selected={selectedIdx===index}
onclick={handleSelectedIdx(index)}
>
<ListItemIcon>{v.icon}</ListItemIcon>
<ListItemText primary={v.text} />
</ListItem>
function handleSelectedIdx(i){
setSelectedIdx(i)}
Run Code Online (Sandbox Code Playgroud)
我是新来的,我不知道该怎么做this.setState
。失败的两种方式都可以让我知道是我错了。任何帮助表示赞赏。
更新:这里我不使用:
{()=>{handleDrawerToggle}}
Run Code Online (Sandbox Code Playgroud)
还是下面的作品为什么会这样呢?你能告诉我们吗?
<IconButton
color="inherit"
aria-label="Open drawer"
edge="start"
onClick={handleDrawerToggle}
className={classes.menuButton}
/>
function handleDrawerToggle() {
setMobileOpen(!mobileOpen); }
const [mobileOpen, setMobileOpen] = React.useState(false);
Run Code Online (Sandbox Code Playgroud) 我是Redux的新手,我创建了一个演示,其中安装了react redux和redux
资料夹结构
src
js
store
index.js
action
index.js
reducers
index.js
index.js ///////**2**
index.js /////////// **1**
App.js .... etc
Run Code Online (Sandbox Code Playgroud)
在1 index.js中,我有以下代码
import index from "./js/index";
Run Code Online (Sandbox Code Playgroud)
在2 index.js中,我有以下代码
import store from "../js/store/index";
import { addArticle } from "../js/actions/index";
window.store=store;
window.addArticle=addArticle;
Run Code Online (Sandbox Code Playgroud)
我启动npm时,所有软件包都更新了,出现以下错误;
./src/js/store/index.js
Module not found: Can't resolve 'redux' in 'E:\reacr-redux\src\js\store'
Run Code Online (Sandbox Code Playgroud)
js / store / index.js
import { createStore } from "redux";
import rootReducer from "../reducers/index";
const store=createStore(rootReducer);
export default store;
Run Code Online (Sandbox Code Playgroud)
reducers / index.js
import { ADD_ARTICLE } from "../constants/action-types"; …
Run Code Online (Sandbox Code Playgroud) 嗨,任何人都可以解释以下代码javascript不会抛出错误也不会显示任何内容
var text = 'outside';
function logIt() {
console.log(text);
var text = 'inside';
};
logIt();
Run Code Online (Sandbox Code Playgroud)