鍍金池/ 問答/HTML/ Vue實(shí)現(xiàn)公告文章的文字從左往右循環(huán)滾動(dòng)的效果怎么做?

Vue實(shí)現(xiàn)公告文章的文字從左往右循環(huán)滾動(dòng)的效果怎么做?

再不操作DOM的前提下,單純使用Vue可以嗎?

回答
編輯回答
擱淺

通過transform實(shí)現(xiàn),為元素綁定一個(gè)transform的style,如下:

<p :style="{transform: `translate(${trans}px)`} ">testtest</p>

然后通過改變trasform的值移動(dòng)文字,如下:

<script>
export default {
   data: function () {
     trans: 0
   },
   mount: function () {
      this.move(this.translate)
   },
   methods: {
     move: function (value) {
     // 實(shí)現(xiàn)滾動(dòng)
     }
   }
}
</script>
2017年6月27日 22:09