<template>
<div class="notebar">
<Card :padding="0" shadow style="width: 220px;height: 100%">
<p slot="title">
<Icon type="md-add-circle" style="float: right;font-size: 20px;cursor: pointer;padding-top: 2px"/>
<Dropdown @on-click="handleChange">
<span style='cursor: pointer'>切換筆記本</span>
<Icon type="ios-arrow-down"></Icon>
<Dropdown-menu slot="list">
<Dropdown-item v-for='item in notebooks' :key='item.id' :name="item.id">{{item.title}}</Dropdown-item>
</Dropdown-menu>
</Dropdown>
</p>
<CellGroup @on-click='cellChange'>
<Cell
v-for='item in notes'
:key="item.id"
:title="item.title||'標(biāo)題為空'"
style="border-bottom: 1px solid #eee"
:name="item.id"
:to="`/notes?notebookId=${$route.query.notebookId}¬eId=${item.id}`"
/>
</CellGroup>
</Card>
</div>
</template>
<script>
import Notebook from '../apis/Notebooks'
import Note from '../apis/Notes'
export default {
data(){
return {
notebooks: null,
notes: null,
curNotebookId: '',
curNoteId: ''
}
},
created(){
Notebook.getNotebooks().then(res=>{
this.notebooks = res.data
this.curNotebookId = this.$route.query.notebookId||res.data[0].id;
Note.getNotes({notebookId: this.curNotebookId}).then(res=>{
this.notes = res.data
this.$emit('setCurNote',res.data[0])
this.curNoteId = res.data[0]?res.data[0].id:'null'
console.log(this.curNoteId)
this.$router.replace({
path: '/notes',
query: {
notebookId: this.curNotebookId,
noteId: this.curNoteId
}
})
})
})
},
methods: {
handleChange(id){
this.curNotebookId = id
Note.getNotes({notebookId:id}).then(res=>{
this.notes = res.data || []
this.curNoteId = res.data[0]?res.data[0].id:'null'
this.$emit('setCurNote',res.data[0])
// 如果筆記本中筆記為空
this.$router.replace({
path: '/notes',
query: {
notebookId: this.curNotebookId,
noteId: this.curNoteId
}
})
})
},
cellChange(id){
let curNote = this.notes.find(item=>item.id===id)
this.$emit('setCurNote',curNote)
}
}
// beforeRouteUpdate(to,from,next){
// console.log(111)
// }
}
</script>
07-6 筆記側(cè)邊欄.md
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門套菜,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)亲善,“玉大人,你說(shuō)我怎么就攤上這事逗柴∮纪罚” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)渣蜗。 經(jīng)常有香客問(wèn)我屠尊,道長(zhǎng),這世上最難降的妖魔是什么袍睡? 我笑而不...
- 正文 為了忘掉前任知染,我火速辦了婚禮,結(jié)果婚禮上斑胜,老公的妹妹穿的比我還像新娘控淡。我一直安慰自己,他們只是感情好止潘,可當(dāng)我...
- 文/花漫 我一把揭開白布掺炭。 她就那樣靜靜地躺著,像睡著了一般凭戴。 火紅的嫁衣襯著肌膚如雪涧狮。 梳的紋絲不亂的頭發(fā)上,一...
- 那天么夫,我揣著相機(jī)與錄音者冤,去河邊找鬼。 笑死档痪,一個(gè)胖子當(dāng)著我的面吹牛涉枫,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播腐螟,決...
- 文/蒼蘭香墨 我猛地睜開眼愿汰,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了乐纸?” 一聲冷哼從身側(cè)響起衬廷,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎汽绢,沒(méi)想到半個(gè)月后吗跋,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡宁昭,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年跌宛,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片久窟。...
- 正文 年R本政府宣布稀颁,位于F島的核電站芬失,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏匾灶。R本人自食惡果不足惜棱烂,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望阶女。 院中可真熱鬧颊糜,春花似錦、人聲如沸秃踩。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)憔杨。三九已至鸟赫,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間消别,已是汗流浹背抛蚤。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像荆虱,于是被迫代替她去往敵國(guó)和親蒿偎。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 屬性mode有3個(gè)可選值:over(默認(rèn))怀读、push诉位、side屬性align有2個(gè)可選值:start(默認(rèn))、en...
- 參考教程 https://neutronx.github.io/django-markdownx/ Django博...
- vuex vuex的核心是一個(gè)抽離出來(lái)的全局倉(cāng)庫(kù)(store),這個(gè)倉(cāng)庫(kù)用來(lái)維護(hù)一些需要在多個(gè)組件中使用的數(shù)據(jù) v...
- Javascript 是 ECMAScript 的實(shí)現(xiàn)和擴(kuò)展菜枷,ES6標(biāo)準(zhǔn)的制定也為Javascript 加入了許多...