我不知道如何isLoading从reducerForm.jsreducer中访问一个布尔标志reducerRegister.js.我已经使用过combineReducers(),我isLoading在表单提交过程中用来禁用按钮.
它的初始状态为false,点击提交后,它会变为true.表单提交成功后,再次isLoading重置false.以下是此问题的相关代码:
actionRegister.js
let _registerUserFailure = (payload) => {
return {
type: types.SAVE_USER_FAILURE,
payload
};
};
let _registerUserSuccess = (payload) => {
return {
type: types.SAVE_USER_SUCCESS,
payload,
is_Active: 0,
isLoading:true
};
};
let _hideNotification = (payload) => {
return {
type: types.HIDE_NOTIFICATION,
payload: ''
};
};
// asynchronous helpers
export function registerUser({ // use redux-thunk for asynchronous dispatch
timezone,
password,
passwordConfirmation,
email,
name
}) …Run Code Online (Sandbox Code Playgroud) 关于解决webpack 2中的别名我有一点问题.无论我做什么我都无法解决这个问题.这是相关代码:
/* webpack.mix.js */
mix.webpackConfig({
module: {
rules: [
{
test: /\.js$/,
loader: 'eslint-loader'
}
]
},
resolve: {
root: path.resolve(__dirname),
// path is reqired at the beggining of file
alias: {
config: 'src/assets/js/config', // this is a config folder
js: 'src/assets/js'
}
}
});
/* router.js */
import { DashboardRoute } from 'config/route-components'
// this import is unresolved
Run Code Online (Sandbox Code Playgroud) 我差不多四个小时都解决不了这个问题,我找不到任何有用的文档来解决这类问题.这是问题,我正在使用pug/jade模板,我想在pug模板中调用函数来转换一些数据这是主模板:
/** main template */
section
each pet in pets
.pet
.photo-column
img(src= pet.photo)
.info-column
h2= pet.name
span.species= (pet.species)
p Age: #{calculateAge(pet.birthYear)} //here I need to call calculateAge function
if pet.favFoods
h4.headline-bar Favorite Foods
ul.favorite-foods
each favFood in pet.favFoods
li!= favFood
/** end main template **/
Run Code Online (Sandbox Code Playgroud)
这是外部功能:
/** calculateAge.js **/
module.exports = function(birthYear) {
var age = new Date().getFullYear() - birthYear;
if (age > 0) {
return age + " years old";
} else {
return "Less than a year …Run Code Online (Sandbox Code Playgroud)