我有这张桌子:
class CreateShoes < ActiveRecord::Migration
def change
create_table :shoes do |t|
t.string :name
t.boolean :leather
t.integer :season
t.timestamps null: false
end
end
end
Run Code Online (Sandbox Code Playgroud)
'season'专栏应该叫'season_id'.我知道我必须写't.rename:season,:season_id',如http://edgeguides.rubyonrails.org/active_record_migrations.html#column-modifiers中所述,但我无法找到正确的语法.应该是吗?
class CreateShoes < ActiveRecord::Migration
def change
create_table :shoes do |t|
t.string :name
t.boolean :leather
t.integer :season
t.timestamps null: false
end
change_table :products do |t|
t.rename :season, :season_id
end
end
end
Run Code Online (Sandbox Code Playgroud)
不行.我在Mac控制台中需要做什么?谢谢!
我有一个div给定的height,height使用jQuery 过渡到更大.过渡到更高的元素div是平滑的transition.由于div扩展转换是linear延迟0.5秒,我还transition用来将7行文本从转换opacity: 0为opacity:1.但是,我希望此转换从上到下(第1行比第2行快一点,比第3行快一点,等等),在div转换之后,而不是一次同时转换所有行.怎么做?代码如下:
$("small").on("click", function() {
$(".post1").toggleClass("show-post");
});
Run Code Online (Sandbox Code Playgroud)
.post1 {
border: 1px solid grey;
margin: 20px auto;
width:33%;
height:125px;
padding:0 10px;
border-radius:4px;
background:#FFFFFF;
color:black;
transition: height 0.5s;
-webkit-transition: height 0.5s;
-moz-transition: height 0.5s;
}
.descr {
opacity:0;
}
small {
position:relative;
left:300px;
bottom:30px;
}
.show-post {
height:350px;
}
.show-post .descr{
opacity:1;
transition:opacity 1s linear;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div …Run Code Online (Sandbox Code Playgroud)我知道它Field有一个onChange属性,您可以从这里传递自己的 FormikonChange道具:https://jaredpalmer.com/formik/docs/api/formik#handlechange-e-reactchangeevent-any-void。
但是,我很难理解这些value[key]传递的位置,因此我可以处理表单中传递的数据。在withFormik(): How to use handleChange中发现我可以将两个回调传递给 Formik 的onChangeprop,但我想知道是否有更好的方法来处理这个问题。
根据回复者的评论进行编辑,谢谢:
我的代码在 onChange 属性中使用这两个回调Field:
export default function FormikForm() {
const onSubmitHandler = (formValues, actions) => {
console.log(formValues);
console.log(actions);
};
const onChangeHandler = (e) => {
console.log(e.target.value);
};
return (
<div>
<h1>This is the Formik Form</h1>
<Formik
initialValues={{
name: "",
email: "",
age: ""
}}
onSubmit={onSubmitHandler}
render={props => {
return (
<Form>
<label>
Name
<Field
name="name" …Run Code Online (Sandbox Code Playgroud) 我需要将 Material UI 图标转换为白色,因为背景是另一种颜色。
我从他们的核心颜色库中导入白色:
import { white } from '@material-ui/core/colors';
Run Code Online (Sandbox Code Playgroud)
所以我可以这样做:
style={{ color: white }}
Run Code Online (Sandbox Code Playgroud)
但是,我收到一条错误消息:
./src/components/footer.js
Attempted import error: 'white' is not exported from '@material-ui/core/colors'.
Run Code Online (Sandbox Code Playgroud)
根据他们的文档,我看不出我做错了什么。我已经彻底研究了为什么会出现此错误但找不到解决方案。
我有一个简单的仪表板组件,它依赖于 React 上下文来管理身份验证。它包含一个自定义挂钩useAuth来提取当前用户以及与身份验证相关的功能:登录、注销等。
这是上下文文件AuthContext.js::
import React, { createContext, useContext, useState, useEffect } from "react";
import { auth } from "../config/firebase";
const AuthContext = createContext();
export function useAuth() {
return useContext(AuthContext);
}
export function AuthProvider({ children }) {
const [currentUser, setCurrentUser] = useState();
const [loading, setLoading] = useState(true);
function signup(email, password) {
return auth.createUserWithEmailAndPassword(email, password);
}
function login(email, password) {
return auth.signInWithEmailAndPassword(email, password);
}
function logout() {
return auth.signOut();
}
useEffect(() => {
const unsubscribe = auth.onAuthStateChanged((user) …Run Code Online (Sandbox Code Playgroud)