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