forked from Gitlink/forgeplus-react
Fix: Add New File Language Api Wrong6
This commit is contained in:
parent
f1614a4b62
commit
85d924db70
|
@ -1,3 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
import React , { useState , useEffect } from 'react';
|
import React , { useState , useEffect } from 'react';
|
||||||
import { Select } from 'antd';
|
import { Select } from 'antd';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -57,28 +59,27 @@ const LANGUAGE = [
|
||||||
|
|
||||||
export default (({ language , select_language })=>{
|
export default (({ language , select_language })=>{
|
||||||
const [ languages , setLanguage ] = useState(undefined);
|
const [ languages , setLanguage ] = useState(undefined);
|
||||||
|
// useEffect(()=>{
|
||||||
useEffect(()=>{
|
// const url = '/dev_ops/languages.json';
|
||||||
const url = '/dev_ops/languages.json';
|
// axios.get(url).then(result=>{
|
||||||
axios.get(url).then(result=>{
|
// if(result){
|
||||||
if(result){
|
// setLanguage(result.data);
|
||||||
setLanguage(result.data);
|
// }
|
||||||
}
|
// }).catch(error=>{
|
||||||
}).catch(error=>{
|
// console.log(error);
|
||||||
console.log(error);
|
// })
|
||||||
})
|
// },[])
|
||||||
},[])
|
|
||||||
|
|
||||||
function changelanguage(value){
|
function changelanguage(value){
|
||||||
let array = value ? languages.filter(item=>item.name === value) :undefined;
|
// let array = value ? languages.filter(item=>item.name === value) :undefined;
|
||||||
select_language(value,array && array[0]);
|
select_language(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<Select showSearch={true} placeholder={"请选择文本语言"} style={{ width: 200 }} value={language} onChange={changelanguage}>
|
<Select showSearch={true} placeholder={"请选择文本语言"} style={{ width: 200 }} value={language} onChange={changelanguage}>
|
||||||
<Option value={undefined}>请选择文本语言</Option>
|
<Option value={undefined}>请选择文本语言</Option>
|
||||||
{languages && languages.map((item, key) => {
|
{LANGUAGE && LANGUAGE.map((item, key) => {
|
||||||
return <Option value={item.name}>{item.name}</Option>;
|
return <Option value={item}>{item}</Option>;
|
||||||
})}
|
})}
|
||||||
</Select>
|
</Select>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue