iview 錨點爬坑

1、看了api,按照其說的做了,發現不能定位,於是網上查資料,有人說是因爲iview 引入vue-router 後錨點就失效了,推薦

這樣寫

  document.getElementById('id').scrollIntoView();

這樣確實可以實現錨點定位,但是不符合我的需求,於是新建項目不加入vue-router ,測試,發現iview 錨點居然就可以定位,但是不死心,又加了vue-router再次測試,發現錨點定位居然還可以用。仔細對比了項目和新建的項目,發現我新建的項目錨點是打在了div 上,而工作項目中錨點在Card上,於是在Card外層套了div,然後打錨點,測試發現錨點可以用了。

結論:vue-router 不影響iview錨點定位,但是錨點必須是打在div上

附代碼:

            <Anchor show-ink>
                <AnchorLink v-for="(filterObject, index) in filterObjects"    :href="'#'+filterObject.name" :title="filterObject.name" :key="index"/>
            </Anchor>
        </Affix>
        <div v-for="(filterObject, index) in filterObjects"  :key="index">
            <div :id="filterObject.name"></div>
            <Card  class="card">
                <p  slot="title">{{ filterObject.comment }}</p>
                <Table  :loading="loading" stripe :columns="columns" :data="filterObject.children" size="small"></Table>
            </Card>
        </div>

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章