File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,35 @@ export default {
19
19
type: [Number , null ],
20
20
default: null
21
21
}
22
+ },
23
+
24
+ mounted () {
25
+ this .init ()
26
+ },
27
+
28
+ methods: {
29
+ init () {
30
+ window .addEventListener (' hashchange' , () => {
31
+ this .focusElement (location .hash .substring (1 ))
32
+ }, false )
33
+
34
+ if (location .hash && location .hash .substring (1 )) {
35
+ console .log (location .hash .substring (1 ))
36
+ this .focusElement (location .hash .substring (1 ))
37
+ }
38
+ },
39
+
40
+ focusElement (id ) {
41
+ if (! id) return
42
+ let element = window .document .getElementById (id)
43
+ if (element) {
44
+ if (! / ^ (a| select| input| button| textarea)/ i .test (element .tagName .toLowerCase ())) {
45
+ console .log (' entrou' )
46
+ element .setAttribute (' tabindex' , - 1 )
47
+ }
48
+ element .focus ()
49
+ }
50
+ }
22
51
}
23
52
}
24
53
</script >
You can’t perform that action at this time.
0 commit comments