Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用choosen语言显示pdf文件_Javascript_Reactjs - Fatal编程技术网

Javascript 如何使用choosen语言显示pdf文件

Javascript 如何使用choosen语言显示pdf文件,javascript,reactjs,Javascript,Reactjs,我是react.js的初学者,这是我的问题。我有一个系统,用户可以选择默认语言。因此,如果语言是法语,我有一个特殊的url放在我的Iframe路径中。如果是西班牙语,一个特殊的pdf。但我怎么才能做到逻辑呢 我有这样的想法: function Iframe(props) { return (<div dangerouslySetInnerHTML={{ __html: props.iframe ? props.iframe : "" }} />); }

我是react.js的初学者,这是我的问题。我有一个系统,用户可以选择默认语言。因此,如果语言是法语,我有一个特殊的url放在我的Iframe路径中。如果是西班牙语,一个特殊的pdf。但我怎么才能做到逻辑呢

我有这样的想法:

function Iframe(props) {
    return (<div dangerouslySetInnerHTML={{ __html: props.iframe ? props.iframe : "" }} />);
}

//defalut pdf cause im not verifying the language yet. 
const iframe = '<iframe src="https://myPDFinFrench.pdf" width="1361" height="550"></iframe>';
const language = 'FR';

const iframeFactory = {
  'ES': 'https://spanish.pdf/',
  'FR': 'https://french.pdf/',
}

function Iframe() {
    const iframe = `<iframe src=${iframeFactory[language]} width="1361" height="550"></iframe>`

    return (<div dangerouslySetInnerHTML={{ __html: iframe }} />);
}
函数Iframe(道具){
返回();
}
//因为我还没有验证语言。
常量iframe='';

您可以使用模板在iframe中有条件地呈现URL,如下所示:

function Iframe(props) {
    return (<div dangerouslySetInnerHTML={{ __html: props.iframe ? props.iframe : "" }} />);
}

//defalut pdf cause im not verifying the language yet. 
const iframe = '<iframe src="https://myPDFinFrench.pdf" width="1361" height="550"></iframe>';
const language = 'FR';

const iframeFactory = {
  'ES': 'https://spanish.pdf/',
  'FR': 'https://french.pdf/',
}

function Iframe() {
    const iframe = `<iframe src=${iframeFactory[language]} width="1361" height="550"></iframe>`

    return (<div dangerouslySetInnerHTML={{ __html: iframe }} />);
}
const language='FR';
常数iframeFactory={
“ES”:https://spanish.pdf/',
“FR”:https://french.pdf/',
}
函数Iframe(){
常数iframe=``
返回();
}

到目前为止,您尝试了什么?你被困在哪里?为什么不使用该语言(无论存储在何处)从不同的PDF文件中进行选择?