Git Product home page Git Product logo

Comments (3)

UzkiS avatar UzkiS commented on September 23, 2024

比如你进入了其他路由,这个路由不存在任何可选焦点,itemArray就被清空了,这个时候就需要通过这段代码清空currentItem,因为其实际已经不存在了
现在想一下为什么 #2 中一定需要在挂载时手动移动到默认焦点也是这个原因,如果切换了路由,新路由中存在其他item,这时候currentItem中存放的还是上一个页面的Item,并不能使用,所以手动move到默认焦点是必要的

from vuepg.

xiaoxiyao avatar xiaoxiyao commented on September 23, 2024

比如你进入了其他路由,这个路由不存在任何可选焦点,itemArray就被清空了,这个时候就需要通过这段代码清空currentItem,因为其实际已经不存在了 现在想一下为什么 #2 中一定需要在挂载时手动移动到默认焦点也是这个原因,如果切换了路由,新路由中存在其他item,这时候currentItem中存放的还是上一个页面的Item,并不能使用,所以手动move到默认焦点是必要的

这个时候应该直接清空currentItem就行了,下面判断没有currentItem就给currentItem赋值,会让人误解

from vuepg.

UzkiS avatar UzkiS commented on September 23, 2024

比如你进入了其他路由,这个路由不存在任何可选焦点,itemArray就被清空了,这个时候就需要通过这段代码清空currentItem,因为其实际已经不存在了 现在想一下为什么 #2 中一定需要在挂载时手动移动到默认焦点也是这个原因,如果切换了路由,新路由中存在其他item,这时候currentItem中存放的还是上一个页面的Item,并不能使用,所以手动move到默认焦点是必要的

这个时候应该直接清空currentItem就行了,下面判断没有currentItem就给currentItem赋值,会让人误解

路由更新仅是一个例子,包括手动移除Item也会导致itemArray被清空。代码逻辑上之后可以考虑在更新itemArray时判断itemArray是否为空,如果为空就清空currentItem,感谢建议

from vuepg.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.