element-ui分頁(yè):
http://element-cn.eleme.io/2....
沒太懂你的意思。不過你說的這個(gè)網(wǎng)站采用的了bootsrap框架和jquery庫(kù)。
router.js
// router用history
const appRouter = {
mode: "history",
routes: [
{
path: "/list",
name: "list",
component: List,
meta: {
keepAlive: true //不刷新
}
}
]
}
App.vue入口文件添加keep-alive
<template>
<div id="app">
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
<router-view v-if="!$route.meta.keepAlive"></router-view>
</div>
</template>
router.js主要代碼(也可以放到main.js)
import { getScrollTop, setScrollTop } from "@/utils/mixin";
let routerList = [];
router.beforeEach((to, from, next) => {
//返回上一級(jí)瀏覽位置
let position = getScrollTop();
let currentRouterIndex = routerList.findIndex(e => {
return e.path === from.fullPath;
});
if (currentRouterIndex != -1) {
routerList[currentRouterIndex].position = position;
} else {
routerList.push({
path: from.fullPath,
position: position
});
}
});
router.afterEach((to, from, next) => {
let savedPosition = routerList.find(e => {
return e.path === to.fullPath;
});
if (typeof savedPosition !== "undefined") {
Vue.nextTick(() => {
setScrollTop(savedPosition.position);
});
} else {
Vue.nextTick(() => {
setScrollTop(0);
});
}
});
utils/mixin.js
/*獲取到頂部的距離*/
export function getScrollTop() {
return (
window.pageYOffset ||
document.documentElement.scrollTop ||
document.body.scrollTop
);
}
/*設(shè)置距離*/
export function setScrollTop(value) {
window.scrollTo(0, value);
}應(yīng)該是this.$emit(eventName,arg);是不是不能像你那樣寫,可以this.$emit("select-house", [houseData, houseId]);
接受selectHouse(data) {
this.agreeForm.houseName = data[0];
this.selectHouseId=data[1]
console.log(this.agreeForm.houseName)
}在app.json中,添加:
{
window:{
"backgroundColor": "#ffffff",
}
}(1) 要使用正確的對(duì)象類型
這里不能用Mesh,因?yàn)檫@里geometry的點(diǎn)數(shù)不滿足Mesh的規(guī)范,圖形是渲染不出來的,Mesh是由小三角面構(gòu)成,頂點(diǎn)數(shù)必須是3的倍數(shù)。所以,這里應(yīng)該用THREE.Line
將:
allLineMesh=new THREE.Mesh(allLine,new THREE.MeshBasicMaterial({color:0x000000,side:THREE.DoubleSide}))
改成:
allLineMesh=new THREE.Line(allLine,new THREE.MeshBasicMaterial({color:0x000000,side:THREE.DoubleSide}))
你會(huì)發(fā)現(xiàn)有圖像出來了,但只有一條直線,下面講這個(gè)問題。
(2)對(duì)對(duì)象使用變換之后,要手動(dòng)更新對(duì)象變換矩陣
在three.js中,考慮到性能,框架在做變換的時(shí)候不會(huì)自動(dòng)更新變換矩陣(其實(shí)還有很多東西都不會(huì)自動(dòng)更新,可以參考文檔里面定義的xxxNeedsUpdate,computeXXX,updateXXX之類的屬性),所以,如果你對(duì)對(duì)象做了變換之后要用到對(duì)象的矩陣,那么你首先需要更新對(duì)象的變換矩陣,可以使用Object3D.updateMatrix()方法。
所以,像下面這種寫法是不能看到geometry有任何改變的:
var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } ) );
line.position.z = ( i * 50 ) - 500; // 這里做了變換,但是沒更新變換矩陣
allLine.merge(line.geometry,line.matrix)//使用原始的變換矩陣,于是對(duì)象的變換并沒有應(yīng)用到geometry上
可以改成:
var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } ) );
line.position.z = ( i * 50 ) - 500;
line.updateMatrix(); // 加了這句
allLine.merge(line.geometry,line.matrix)
現(xiàn)在可以看到圖像了,但是你會(huì)發(fā)現(xiàn)圖像很奇怪:
這是什么鬼?為什么有那么多交叉線?
其實(shí)這和Line類型的繪制策略有關(guān),Line是把vertices的點(diǎn)一個(gè)一個(gè)連起來的,比如vertices里有四個(gè)點(diǎn)[A,B,C,D],那么Line在畫的時(shí)候,就是A-->B-->C--D,而你想的可能是A-->B,C-->D,簡(jiǎn)單驗(yàn)證一下,使用下面的函數(shù):
function initObject(){
var material = new THREE.LineBasicMaterial({
color: 0x0000ff
});
var geometry = new THREE.Geometry();
geometry.vertices.push(
new THREE.Vector3( -500, 0, 0 ),
new THREE.Vector3( 500, 0, 0 ),
new THREE.Vector3( 0, 0, -500 ),
new THREE.Vector3( 0, 0, 500 )
);
var line = new THREE.Line( geometry, material );
scene.add( line );
}
運(yùn)行的結(jié)果如下圖:
確實(shí)是A-->B-->C--D這樣連的
(3)利用吸附算法使中間連線吸附到邊緣
對(duì)于Line的A-->B-->C--D這種畫法我們是沒辦法改變,但是,在這個(gè)例子中,我們可以人為的將B-->C邊吸附到邊緣。比如有個(gè)上面四個(gè)點(diǎn)的坐標(biāo)如下:
A:[1,0,0]
B:[-1,0,0]
C:[0,0,1]
D:[0,0,-1]
我們可以人為的插一個(gè)點(diǎn)E:
A:[1,0,0]
B:[-1,0,0]
E:[-1,0,1]
C:[0,0,1]
D:[0,0,-1]
使得B-->C由斜線變成了沿著邊緣走的斜線:
吸附算法如下:
// 吸附算法
function adsorb(geometry,compares){
var vertices = geometry.vertices;
var cdt1 = compares[0];
var cdt2 = compares[1];
for (var i = 0 ; i < vertices.length-1; i++) {
var vertice = vertices[i];
var nextVertice = vertices[i+1];
if(Math.round(vertice[cdt1]) !== Math.round(nextVertice[cdt1])
&& Math.round(vertice[cdt2]) !== Math.round(nextVertice[cdt2])){ // 差異超過兩個(gè)維度
var vector = new THREE.Vector3();
vector[cdt1] = vertice[cdt1];
vector[cdt2] = nextVertice[cdt2];
vertices.splice(i+1, 0,vector); // 插入一個(gè)點(diǎn)
i++;
}
}
geometry.vertices = vertices;
}
將吸附算法加入到創(chuàng)建過程中:
function initObject() {
var geometry = new THREE.Geometry();
var allLine=new THREE.Geometry();
geometry.vertices.push( new THREE.Vector3( - 500, 0, 0 ) );
geometry.vertices.push( new THREE.Vector3( 500, 0, 0 ) );
for ( var i = 0; i <= 20; i ++ ) {
var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } ) );
line.position.z = ( i * 50 ) - 500;
line.updateMatrix();
allLine.merge(line.geometry,line.matrix)
var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } ) );
line.position.x = ( i * 50 ) - 500;
line.rotation.y = 90 * Math.PI / 180;
line.updateMatrix();
allLine.merge(line.geometry,line.matrix)
}
adsorb(allLine,["x","z"]); // 添加這一行
allLine.verticesNeedUpdate = true;
allLineMesh=new THREE.Line(allLine,new THREE.MeshBasicMaterial({color:0x000000,side:THREE.DoubleSide}))
scene.add( allLineMesh );
}
這樣看起來就正確了
已經(jīng)解決了,寫法沒錯(cuò),應(yīng)用錯(cuò)DOM結(jié)構(gòu)了,由于樣式覆蓋,導(dǎo)致效果沒出來
這么能做成了橫向全屏嗎?
現(xiàn)行的數(shù)據(jù)結(jié)構(gòu)是一個(gè)數(shù)組,可以對(duì)這個(gè)數(shù)組進(jìn)行循環(huán),相同的區(qū)的item存入一個(gè)數(shù)組,數(shù)據(jù)結(jié)構(gòu)由一個(gè)一層數(shù)組,變成一個(gè)兩層的數(shù)組,然后可以在頁(yè)面中顯示
.如果報(bào)錯(cuò)是[Vue warn]: Cannot find element: #root,那么你就要在 index.vue 中加上
<div id="root"> </div>
這是個(gè)bug.
解決方案如下:
const win = new electron.BrowserWindow({
width: 600,
height: 400,
show: false
})
win.once('ready-to-show', () => {
win.webContents.setZoomFactor(1.0)
win.show()
})(press)="function()"
建議不要使用數(shù)組來儲(chǔ)存數(shù)據(jù),其實(shí)我猜想你的本意是想要一個(gè)dom類的數(shù)據(jù)類型,那何不用對(duì)象來操作呢,直接對(duì)每個(gè)字符串進(jìn)行操作,轉(zhuǎn)成一個(gè)類似dom的數(shù)組,方法思路也現(xiàn)成,就是dom解析。
transition需要觸發(fā)時(shí)機(jī),比如一個(gè)div你想要他transition,可以通過點(diǎn)擊這個(gè)div,然后給這個(gè)div的css屬性里面增加一個(gè)transform: translateY(1000rpx),這樣div就會(huì)在你點(diǎn)擊之后從原始位置運(yùn)動(dòng)到1000rpx,總結(jié)起來就是需要某個(gè)觸發(fā)時(shí)機(jī),如果你想不通過任何觸發(fā)事件去實(shí)現(xiàn)你想要的translateY(1000rpx)的效果,可以使用動(dòng)畫。
animation: animate 0.4s ease-out;
然后指明這個(gè)動(dòng)畫:
@keyframes animate {
from {
transform: translateX(0px);
}
to {
transform: translateX(500px);
}
}2秒你這。。??赡苁且韵聠栴}:
1、設(shè)備不行
2、切換動(dòng)畫時(shí)間過長(zhǎng)或動(dòng)畫效果不行
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問,美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。