把渲染方法抽離出來,每次操作都重新執(zhí)行此函數(shù),重新渲染
for循環(huán)是可以的。
var nodeList = document.getElementsByTagName('div');
for (var i = 0; i < nodeList.length; i++) {
// code here
console.log(1);
}
面試官可能更希望你回答出,這是array-like-object 類數(shù)組對(duì)象,怎么轉(zhuǎn)換成數(shù)組。再做循環(huán)。
方案一:ES5 Array.prototype.slice.call
var nodeList = document.getElementsByTagName('div'));
var nodeArr = Array.prototype.slice.call(nodeList);
// [].slice.call() 這個(gè)也可以
Array.isArray(nodeArr); // true
nodeArr.forEach(() => {
console.log(1);
});
方案二:ES6 擴(kuò)展符 ...
// NodeList對(duì)象
var nodeArr = [...document.querySelectorAll('div')];
nodeArr.forEach(() => {
console.log(1);
});
方案三:ES6 Array.from
Array.from(document.querySelectorAll('div')).forEach(() => {
// code here
console.log(1);
});
面試官應(yīng)該是想要你說出轉(zhuǎn)成數(shù)組這三種方案。希望對(duì)你有幫助~
自己解決了,關(guān)鍵是重新初始化了數(shù)據(jù),每次彈出框的時(shí)候,將數(shù)據(jù)拷貝一份,傳入組件,
每次重新渲染組件的方式就是用v-if
<synctree v-if="reloadTree" :data.sync="tempList" v-model="finalData"></synctree>
每次點(diǎn)擊的時(shí)候重新渲染,不過這樣有個(gè)弊端,數(shù)據(jù)多了性能差,希望大家能有其他的解決辦法
handleAdd() {
this.reloadTree = true
// 拷貝數(shù)據(jù)
this.tempList = deepClone(this.originData)
// 修改不可選數(shù)據(jù)disabled屬性
this.disabledKeys.forEach(key => {
this.tempList.forEach(item => {
if (key === item.id) {
this.$set(item, 'disabled', true)
}
})
})
// 顯示彈框
this.dialogVisible = true
},
閑了會(huì)去整理一個(gè)小的demo出來,歡迎去我的github圍觀
我覺得是純手打的,因?yàn)楹芏嘭Q直方向的邊界線都沒有對(duì)齊,markdown也沒有對(duì)應(yīng)的支持,另外如果不是純文本環(huán)境的話,這種圖形還是化成圖比較好,又是矩形又是箭頭的
先說一個(gè)最原始的方法實(shí)現(xiàn)
class Dispatcher {
constructor() {
this._event = [];
}
on(eventName, fn) {
var subscription = {
eventName,
callback: fn
};
this._event.push(subscription);
return this;
}
off(eventName, fn) {
this._event = this._event.filter(
subscription => !(subscription.eventName === eventName && (fn ? subscription.callback === fn : true))
);
return this;
}
emit(eventName, ...data) {
this._event.forEach(subscription => {
if (subscription.eventName === eventName) {
subscription.callback(...data);
}
});
return this;
}
}
var leftList = [
{productId: 10006},
{productId: 10031},
{productId: 10016},
{productId: 10017},
];
var leftList = leftList.map((item, index) => ({...item, order: index,}));
var rightList = [];
var dispatch = new Dispatcher();
dispatch.on('select', function(product) {
leftList = leftList.filter(_product => product !== _product);
rightList.push(product);
});
dispatch.on('unselect', function(product) {
rightList = rightList.filter(_product => product !== _product);
leftList.push(product);
});
dispatch.emit('select', leftList[0]);
console.log('leftList: ', [...leftList],'\n', 'rightList', [...rightList]);
dispatch.emit('unselect', rightList[0]);
console.log('leftList: ', [...leftList],'\n', 'rightList', [...rightList]);
然后再說一個(gè)比較Vue的,左右兩列應(yīng)該算兄弟組件之間的通信,組件的代碼和視圖的代碼應(yīng)該在兩個(gè)js文件。組件的通信可以通過子組建1 -> 父組件 -> 子組建2,但是比較麻煩。
我感覺可以用Vuex了。
使用ended事件
var audio = document.getElementById("audio");
audio.loop = false;
audio.addEventListener('ended', function () {
//換地址
}, false);chrome cookie不支持本地協(xié)議,就是通過file://xxx.html這樣子訪問
如果你把該文件通過web服務(wù)器訪問就可以。
<body>
<a class="qs">簽收1</a>
<a class="qs">簽收2</a>
<a class="qs">簽收3</a>
<a class="qs">簽收4</a>
<script>
$(".qs").on('click', function() {
$(this).context.innerText = 'xxx'
})
</script>
先全局裝個(gè) rimraf, 然后嘗試:
npm install -g rimraf
rimraf node_modules
npm install
npm 版本是多少? 如果有 package-lock.json 這個(gè)文件,則先刪除再 npm install
補(bǔ)充:
npm install babel-preset-react -D
在項(xiàng)目根目錄新建個(gè)文件 .babelrc, 把 package.json 里的 babel 刪掉。
{
"presets": ["env", "react"]
}我覺得還是你的布局的代碼沒寫對(duì),不是因?yàn)閝uill自動(dòng)獲取了焦點(diǎn)
+event.target.value會(huì)把小數(shù)點(diǎn)過濾掉,所以必須把+去掉
handleChange(event) {
this.setState({value: event.target.value});
}<img :src="placeImg" >
export default {
props: {
placeImg: require('~/assets/img/abc.png')
}
想要轉(zhuǎn)換成這種?
let result = [{id: '1'}, {id: '1'}, {id: '3'}];
let ids = ['1', '2', '3'];
let result = ids.map(el => {
return {
id: el
};
});目前使用一條曲線作為基礎(chǔ)線,再加第二條曲線模擬圓點(diǎn),再加第三條曲線覆蓋第二條曲線只剩個(gè)頭。
勉強(qiáng)實(shí)現(xiàn)了需求。不好的地方是圓點(diǎn)只能用顏色做區(qū)分,不能更大。
emmmmm 吃飯前等人,就簡單實(shí)現(xiàn)了一個(gè),但是不知道兼容性咋樣。。主要用的就是 css3 的 clip 屬性
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div {
width: 400px;
height: 40px;
line-height: 40px;
text-align: center;
}
.progress-container {
position: relative;
border: 1px solid black;
font-size: 28px;
}
.skyblue {
position: absolute;
top: 0;
z-index: 1;
background: skyblue;
color: white;
}
.white {
position: absolute;
top: 0;
z-index: 2;
background: white;
color: skyblue;
clip: rect(auto auto auto 194px);
}
</style>
</head>
<body>
<div class="progress-container">
<div class="skyblue">50%</div>
<div class="white">50%</div>
</div>
</body>
</html>
原理大概這樣:
包裹的容器里有兩個(gè)初始定位一樣的 div
底下的 div 長這樣:
上面的 div 長這樣:
之后根據(jù)進(jìn)度用 js 來調(diào)整 clip: rect(top, right, bottom, left) 中的屬性值就行了,這個(gè)例子里調(diào)整的是 left 值
看不到你的html文件的問題,感覺用/static根路徑不太對(duì),相對(duì)路徑應(yīng)該不會(huì)出錯(cuò)。
已經(jīng)解決,因?yàn)榭缬騿栴}
設(shè)置為checkStrictly時(shí),組件完全變成可控組件。
子父關(guān)系沒有關(guān)聯(lián)。
github 上這個(gè)項(xiàng)目已經(jīng)廢棄了,報(bào)錯(cuò)是這個(gè)項(xiàng)目引用的還是舊版本 React,新版本 React 已經(jīng)不自帶 PropTypes 了。
PS:試試這個(gè)react-native-swiper?
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國職業(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庫,具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。