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 { Select } from 'antd';
|
||||
import axios from 'axios';
|
||||
|
@ -57,28 +59,27 @@ const LANGUAGE = [
|
|||
|
||||
export default (({ language , select_language })=>{
|
||||
const [ languages , setLanguage ] = useState(undefined);
|
||||
|
||||
useEffect(()=>{
|
||||
const url = '/dev_ops/languages.json';
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
setLanguage(result.data);
|
||||
}
|
||||
}).catch(error=>{
|
||||
console.log(error);
|
||||
})
|
||||
},[])
|
||||
// useEffect(()=>{
|
||||
// const url = '/dev_ops/languages.json';
|
||||
// axios.get(url).then(result=>{
|
||||
// if(result){
|
||||
// setLanguage(result.data);
|
||||
// }
|
||||
// }).catch(error=>{
|
||||
// console.log(error);
|
||||
// })
|
||||
// },[])
|
||||
|
||||
function changelanguage(value){
|
||||
let array = value ? languages.filter(item=>item.name === value) :undefined;
|
||||
select_language(value,array && array[0]);
|
||||
// let array = value ? languages.filter(item=>item.name === value) :undefined;
|
||||
select_language(value);
|
||||
}
|
||||
|
||||
return(
|
||||
<Select showSearch={true} placeholder={"请选择文本语言"} style={{ width: 200 }} value={language} onChange={changelanguage}>
|
||||
<Option value={undefined}>请选择文本语言</Option>
|
||||
{languages && languages.map((item, key) => {
|
||||
return <Option value={item.name}>{item.name}</Option>;
|
||||
{LANGUAGE && LANGUAGE.map((item, key) => {
|
||||
return <Option value={item}>{item}</Option>;
|
||||
})}
|
||||
</Select>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue