Comments (3)
比如你进入了其他路由,这个路由不存在任何可选焦点,itemArray就被清空了,这个时候就需要通过这段代码清空currentItem,因为其实际已经不存在了
现在想一下为什么 #2 中一定需要在挂载时手动移动到默认焦点也是这个原因,如果切换了路由,新路由中存在其他item,这时候currentItem中存放的还是上一个页面的Item,并不能使用,所以手动move到默认焦点是必要的
from vuepg.
比如你进入了其他路由,这个路由不存在任何可选焦点,itemArray就被清空了,这个时候就需要通过这段代码清空currentItem,因为其实际已经不存在了 现在想一下为什么 #2 中一定需要在挂载时手动移动到默认焦点也是这个原因,如果切换了路由,新路由中存在其他item,这时候currentItem中存放的还是上一个页面的Item,并不能使用,所以手动move到默认焦点是必要的
这个时候应该直接清空currentItem就行了,下面判断没有currentItem就给currentItem赋值,会让人误解
from vuepg.
比如你进入了其他路由,这个路由不存在任何可选焦点,itemArray就被清空了,这个时候就需要通过这段代码清空currentItem,因为其实际已经不存在了 现在想一下为什么 #2 中一定需要在挂载时手动移动到默认焦点也是这个原因,如果切换了路由,新路由中存在其他item,这时候currentItem中存放的还是上一个页面的Item,并不能使用,所以手动move到默认焦点是必要的
这个时候应该直接清空currentItem就行了,下面判断没有currentItem就给currentItem赋值,会让人误解
路由更新仅是一个例子,包括手动移除Item也会导致itemArray被清空。代码逻辑上之后可以考虑在更新itemArray时判断itemArray是否为空,如果为空就清空currentItem,感谢建议
from vuepg.
Related Issues (2)
- 第一次焦点移动问题 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuepg.