lzxb / vuet Goto Github PK
View Code? Open in Web Editor NEW允许你定义飙车过程的集中式状态管理模式
License: MIT License
允许你定义飙车过程的集中式状态管理模式
License: MIT License
import { mapModules, mapRules } from 'vuet'
export default {
mixins: [
mapModules({ data2: 'topic-detail'}),
mapRules({ route: 'topic-detail' })
],
computed:{
topic(){
return this.data2.topic
}
},
mounted(){
console.log(JSON.stringify(this.data2)) //这里打印出来都是空值,为什么呢
var imgs=this.topic;
console.log(JSON.stringify(imgs)) //这里打印出来都是空值,为什么呢
}
}
import {addressList} from '@/api'
import { mapModules, mapRules } from 'vuet'
const mixins = [
mapModules({
$address: 'address'
}),
mapRules({
once: [{ path: 'address' }]
})
]
export default {
mixins,
module: {
data () {
return {
data: ''
}
},
fetch (uid) {
setTimeout(() => {
this.data = 'fetch'
}, 1000)
},
async getData(uid = 1) {
setTimeout(() => {
this.data = 111
}, 1000)
return
let res = await addressList({uid})
this.data = res.data
}
}
}
这么写 data 返回的 居然是 function proxy() { return native.apply(vuet.modules[path], arguments); }
看文档,感觉优势没有说的很明显,也没有详尽的使用文档。
完全不知道怎么用,没跑起来
vuet.js 啥时可以支持下拉刷新呢
你好,我在项目中使用发现 Object.assign 方法报错,此方法的 polyfill 没包含在包中。
测试机:
应该这样吧。
modules: {
topic: {
modules: {
list: {
然后mapModules的时候驼峰貌似也不对啊,父子的只能用/吧
mixins: [
mapRules({ route: 'topic/list' }),
mapModules({ list: 'topic/list' })
],
我在vuet中定义了一个模块,用来显示“图片幻灯片”,
运行起来后,第一次是正常的,但是点击其中一张图片进去查看之后,再点击返回,图片幻灯片成倍显示了,代码如下
vuet模块代码如下
modules: {
topic: {
modules: {
slider:{
data () {
return {
list: []
}
},
route: {
once: true // 当前页面,只加载一次,这样我们就可以做上拉加载了
},
async fetch () {
const res = await http.get('News/slides?time='+Math.random())
//alert(res.data);
this.list = [...this.list, ...res.data]
}
}
}
}
}
调用页面代码如下
export default {
mixins: [
mapModules({ data: 'topic-newslist',pic:'topic-slider' }),
mapRules({ route: 'topic-newslist' })
],
mounted(){
this.pic.fetch();
}
}
假如列表存在翻页,进入详细页返回时,列表只有第一页。
router使用keep-alive时,vuet-scroll无效
在字典画面设置reset:['dict'],
然后返回业务画面时,once:['dict']没有重新
触发。
按照常理,rest后,不应该把'dict'重置为最初状态嘛?
有没有严格模式的设置,不知道vuet在设计时是不是遵循了单向数据流的概念。如果遵循了单向数据流,那么怎么设置才能不直接修改变量造成了ui改变?
比如我的vuet代码
//vuet 代码
export default new Vuet({
pathJoin: '-',
modules: {
topic: {
data () {
return {
count: 0
}
}
,addCount:function(){
this.count ++;
}
,modules:{
list:{
data(){
return {
name:"list"
}
}
}
}
}
}
});
//vue页面代码
<template>
<div>
{{topic.count}}
<button @click="addEvent">++</button>
</div>
</template>
<script>
export default{
mixins: [
mapModules({
topic: 'topic' // { 别名: '模块路径' }
,list:'topic-list'
})
]
,methods:{
addEvent:function(){
(this.topicModel.count)++
}
}
}
</script>
上述的代码中通过addEvent直接就操作了store中的属性,这是案例说违反了单向数据流的严格模式。在严格模式中属性的改变应该通过action来驱动。
出了vuex还有mobx类库,这个类库默认情况也是可以直接修改属性,但是可以配置一下变成严格模式,严格模式下就只能通过action来改变属性。
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.