lin-xin / notepad Goto Github PK
View Code? Open in Web Editor NEW基于vue2.0+vuex+localStorage+sass+webpack,实现一个本地存储的记事本。兼容PC端和移动端。
Home Page: https://lin-xin.gitee.io/example/notepad/
基于vue2.0+vuex+localStorage+sass+webpack,实现一个本地存储的记事本。兼容PC端和移动端。
Home Page: https://lin-xin.gitee.io/example/notepad/
notapad () {
let self = this
let typeFilter = () => self.screen_type ? todo => todo.type === self.screen_type : todo => todo
let titleFilter = () => self.screen_title
? todo => todo.content.indexOf(self.screen_title) !== -1
: todo => todo
return self.$store.getters.getEventList.filter(typeFilter()).filter(titleFilter())
// return self.$store.getters.getEventList.filter(function (d) {
// if (self.screen_type !== 0 && self.screen_title === '') {
// if (d.type === self.screen_type) {
// return d
// }
// } else if (self.screen_type !== 0 && self.screen_title !== '') {
// if (d.type === self.screen_type && d.content.indexOf(self.screen_title) !== -1) {
// return d
// }
// } else if (self.screen_type === 0 && self.screen_title !== '') {
// if (d.content.indexOf(self.screen_title) !== -1) {
// return d
// }
// } else {
// return d
// }
// })
},
问题重现步骤:
这时实际取消的是列表中的第一个事件,看代码发现,是由于addevent方法中的新id算法造成的。
ADDEVENT(states,obj){ **let len = states.event.length + 1;** obj.items.id = len; states.event.unshift(obj.items); local.set(states.event); }
[type.EVENTDONE](states, obj) {
for (let i = 0; i < states.event.length; i++) {
if (states.event[i].id === obj.id) {
states.event[i].type = 2 //这里改变了类型
states.event[i].time = func.getDate()
var item = states.event[i]
states.event.splice(i, 1) //删掉了
break
}
}
states.event.unshift(item) //这里又添加回数组顶部
func.local.set(states)
},
尝试着将这个作为小工具集成到项目中,集成过程中发现存在如下问题:
1.每个vue的布局不独立,互相影响,这个是封装大忌,最好每个子vue的布局都需要用一个大括号包进去,且不能被外部影响。
2.使用全局的toast不好。
3.App.vue中存在影响子vue样式的css,如button。
总体来说还是挺好的,稍微修改了一下,完成了集成。作为小工具使用使用挺不错。
比如我定义了一个userModel和otherModel。
在userModel内部state为一个对象{}。
mutations获取参数,当前的state和传递过来的payload。
此时我想改变state这个对象,不能直接去改变参数里面的state。
必须循环一个个遍历state对象的值,payload有相同字段的则覆盖,不同的则添加。
const userModule = {
state: {
username: '',
token: ''
},
mutations: {
updateUser: (state, payload) => {
// ...
}
}
}
你好,当事项内容超出屏幕时,滑动滚轮,侧边栏随之滑下,无法完全覆盖。
在app.vue中有如下代码
import nHeader from './components/header.vue'; import nFooter from './components/footer.vue'; import nAdd from './components/event_add.vue'; import nTable from './components/event_table.vue'; import nList from './components/event_list.vue'; import nSidebar from './components/sidebar.vue'; import nDialog from './components/dialog.vue'; import nTheme from './components/theme.vue';
其中n前缀的用意是什么?
你好,我看到你切换皮肤的方式是采用sass,可是这是在开发环境上,如果实在生产环境中,这样还有效吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.