vue項(xiàng)目中怎樣嵌入其它項(xiàng)目的頁(yè)面
vue項(xiàng)目嵌入其它項(xiàng)目的頁(yè)面
通過iframe嵌入,src的路徑在static中(vue-cli3在public)配置
編譯打包時(shí),不會(huì)將static/public里的文件編譯,前端可修改index.js里的url
方式一
創(chuàng)建index.js,在入口頁(yè)面中引入
static/urls/index.js
window.urlsPath = { statisticsUrl: 'http://xx.xx.xx.xx:80' }
入口index.html
// 注意引入js時(shí)的路徑 // statis <script src="/static/urls/index.js"></script> // public <script src="./urls/index.js"></script>
statistics.js
<iframe src="url" frameborder="0" width="100%" height="100%"></iframe> created() { this.url = window.urlsPath.statisticsUrl + '#/dataStatistics?userId=' + sessionStorageGet('loginData').userId }
方式二
通過在main.js中請(qǐng)求json文件的方式,拿到url
new Vue({ router, store, render: h => h(App), created() { axios.get('/urls/urls.json').then(res=> { if(res.data.code === '0') { utils.sessionStorageSet('defaultConfig', res.data.data) } }) } }).$mount('#app');
以vue-cli3為例,public/urls/urls.json
{ "code":"0", "data":{ "statisticsUrl": "http://xx.xx.xx.xx:80" } }
vue嵌入本地html頁(yè)面
問題描述:
向vue項(xiàng)目中嵌入html頁(yè)面
失敗原因:
代碼結(jié)構(gòu)不同,需要放到指定位置
解決:
把本地html、css\js\img都放到與src同級(jí)的public\static下
嵌入代碼
<template> <div style="width: 100%"> <!--靜態(tài)html資源--> <div> <iframe src="/static/demo01.html" scrolling="auto" frameborder="0" style="width: 100%;height: 900px;"></iframe> </div> </div> </template>
<script> export default { data() { return { } }, methods: { }, created() { } } </script>
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue-create創(chuàng)建VUE3項(xiàng)目詳細(xì)圖文教程
create-vue是Vue官方新的腳手架工具,底層切換到了vite(下一代前端工具鏈),為開發(fā)提供極速響應(yīng),下面這篇文章主要給大家介紹了關(guān)于vue-create創(chuàng)建VUE3項(xiàng)目的相關(guān)資料,需要的朋友可以參考下2024-03-03vue實(shí)現(xiàn)動(dòng)態(tài)表格提交參數(shù)動(dòng)態(tài)生成控件的操作
這篇文章主要介紹了vue實(shí)現(xiàn)動(dòng)態(tài)表格提交參數(shù)動(dòng)態(tài)生成控件的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-11-11Vue3根據(jù)動(dòng)態(tài)字段綁定v-model的操作代碼
最近在學(xué)習(xí)vue技術(shù),開發(fā)表格的時(shí)候,想把表格做成組件,那查詢條件就需要?jiǎng)討B(tài)生成,這就遇到一個(gè)問題,vue怎么動(dòng)態(tài)給v-model變量值,本文通過實(shí)例代碼給大家介紹,對(duì)Vue3動(dòng)態(tài)綁定v-model實(shí)例代碼感興趣的朋友一起看看吧2022-10-10Vue項(xiàng)目創(chuàng)建首頁(yè)發(fā)送axios請(qǐng)求的方法實(shí)例
這篇文章主要給大家介紹了關(guān)于Vue項(xiàng)目創(chuàng)建首頁(yè)發(fā)送axios請(qǐng)求的相關(guān)資料,文中通過圖文以及實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-02-02html頁(yè)面引入vue組件之http-vue-loader.js解讀
這篇文章主要介紹了html頁(yè)面引入vue組件之http-vue-loader.js解讀,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04