react 彈出並打開新窗口 引入public中的圖片


// 首先配置路由並隱藏菜單欄
const routes = [
  {
  name: '投保綜合查詢保單詳情頁',
    icon: 'smile',
    path: '/insureOfQuery/components/details',
    component: './InsureOfQuery/components/Details',
    // 隱藏菜單欄
    menuRender: false,
    // 隱藏菜單
    hideInMenu: true,
  }
];

 

export default routes;
 
 
const jumpDetails = () => {
  const url = '/insureOfQuery/components/details?需要傳遞的數據' + ’需要傳遞的數據‘
  window.open(url, '_blank', 'height=955,width=1269')?.focus() // 設置寬高 為 新頁面 大小   _blank 代表新頁面展示
}
 
//如何在新頁面獲取數據
 
useEffect(() => {
    // 獲取信息
    let obj = window.location
    console.log(obj, 'obj');
}, [])
// 打印出window.location   會在search屬性中看到傳遞的字符串信息   通過截取 獲得自己想要的參數
 
在表格columns中配置
{
    title: '投保單號',
    width: 300,
    align: 'center',
    dataIndex: 'callNumber',
    render: (callNumber) => <a style={{color: 'black'}} onClick={jumpDetails}>
      {callNumber}
    </a>
},
 
 
 
  
 
 
如圖所示 如果 直接引入public下的圖片   直接 引入就可以
export default () => {
  return (
    <ProCard bordered>
      <img src="/logo.png"/>
    </ProCard>
  )
}
 
如果是icon文件下    <img src="/icons/icon-128×128.png"/>    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM