diff --git a/src/js/anot-touch.js b/src/js/anot-touch.js
index 692abbc..d5a7464 100644
--- a/src/js/anot-touch.js
+++ b/src/js/anot-touch.js
@@ -3365,6 +3365,10 @@ const _Anot = (function() {
var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1)
+ attr.value = attr.value.replace(/\(.*\)$/, '')
+ if (vm.$id.slice(0, 11) === '$proxy$each') {
+ vm = vm.$up
+ }
if (
vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function'
diff --git a/src/js/anot-touch.shim.js b/src/js/anot-touch.shim.js
index 3187554..d20cf27 100644
--- a/src/js/anot-touch.shim.js
+++ b/src/js/anot-touch.shim.js
@@ -3380,6 +3380,10 @@
var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1)
+ attr.value = attr.value.replace(/\(.*\)$/, '')
+ if (vm.$id.slice(0, 11) === '$proxy$each') {
+ vm = vm.$up
+ }
if (
vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function'
diff --git a/src/js/anot.js b/src/js/anot.js
index 2926abc..024f44e 100644
--- a/src/js/anot.js
+++ b/src/js/anot.js
@@ -3365,6 +3365,10 @@ const _Anot = (function() {
var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1)
+ attr.value = attr.value.replace(/\(.*\)$/, '')
+ if (vm.$id.slice(0, 11) === '$proxy$each') {
+ vm = vm.$up
+ }
if (
vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function'
diff --git a/src/js/anot.shim.js b/src/js/anot.shim.js
index 5b619db..cc4613d 100644
--- a/src/js/anot.shim.js
+++ b/src/js/anot.shim.js
@@ -3380,6 +3380,10 @@
var camelizeName = camelize(name)
if (camelizeName.indexOf('@') === 0) {
camelizeName = camelizeName.slice(1)
+ attr.value = attr.value.replace(/\(.*\)$/, '')
+ if (vm.$id.slice(0, 11) === '$proxy$each') {
+ vm = vm.$up
+ }
if (
vm.hasOwnProperty(attr.value) &&
typeof vm[attr.value] === 'function'
diff --git a/src/js/form/index.js b/src/js/form/index.js
index 59a2b8a..d0efa65 100644
--- a/src/js/form/index.js
+++ b/src/js/form/index.js
@@ -57,7 +57,7 @@ Anot.component('button', {
return
}
if (typeof this.props.click === 'function') {
- this.props.click()
+ this.props.click(this.props.prop)
}
}
}
@@ -299,6 +299,9 @@ Anot.component('input', {
this.active = false
},
onKeyup(ev) {
+ if (this.disabled) {
+ return
+ }
if (ev.keyCode === 13) {
if (typeof this.props.submit === 'function') {
this.props.submit()
diff --git a/src/js/router/index.js b/src/js/router/index.js
index 41b818e..b9106da 100644
--- a/src/js/router/index.js
+++ b/src/js/router/index.js
@@ -28,6 +28,7 @@ const DEFAULT_OPTIONS = {
prefix: /^(#!|#)[\/]?/, //hash前缀正则
allowReload: true //连续点击同一个链接是否重新加载
}
+const LINKS = []
const RULE_REGEXP = /(:id)|(\{id\})|(\{id:([A-z\d\,\[\]\{\}\-\+\*\?\!:\^\$]*)\})/g
class Router {
@@ -170,7 +171,13 @@ class Router {
this.last = this.path
this.path = path
-
+ LINKS.forEach(vm => {
+ if (vm.rule.test(this.path)) {
+ vm.active = true
+ } else {
+ vm.active = false
+ }
+ })
for (let i = 0, route; (route = this.table[i++]); ) {
let args = path.match(route.regexp)
if (args) {
@@ -220,11 +227,19 @@ class Router {
Anot.component('link', {
__init__(props, state, next) {
+ if (!Anot.router) {
+ return Anot.error('使用前,请先初始化路由')
+ }
let { mode } = Anot.router.options
if (!props.to) {
return
}
-
+ this.setAttribute(':class', '{active: active}')
+ state.rule = Anot.router.__parseRule__(
+ props.to.replace(/^[\/]+|[\/]+$|\s+/g, ''),
+ {}
+ ).regexp
+ props.label = props.label || this.textContent
if (mode === 'hash') {
state.link = '#!' + props.to
} else {
@@ -236,8 +251,14 @@ Anot.component('link', {
render() {
return ''
},
+ skip: ['rule'],
+ componentDidMount() {
+ this.active = this.rule.test(Anot.router.path)
+ LINKS.push(this)
+ },
state: {
- link: ''
+ link: '',
+ active: false
},
props: {
label: ''
diff --git a/src/js/tree/index.js b/src/js/tree/index.js
index 22ce836..2333810 100644
--- a/src/js/tree/index.js
+++ b/src/js/tree/index.js
@@ -106,6 +106,7 @@ export default Anot.component('tree', {
}
},
state: {
+ expand: false,
__LIST_DICT__: {},
list: [],
value: null,