particles.js vue
时间: 2023-10-28 16:24:25 浏览: 91
在Vue中使用particles.js,你需要首先引入particles.js库。如果你只在单个文件中使用,可以在当前vue文件的script中引入,如下所示:
```javascript
import particles from 'particles.js'
```
接下来,在挂载结束后初始化particles.js。你需要通过指定id和data路径来加载particles.json配置文件。例如,如果你的id为"particles",并且将particles.json文件放在public目录下,你可以这样写:
```javascript
mounted() {
particlesJS.load('particles', '/particles.json', function () {
console.log('callback - particles.js config loaded');
});
}
```
这样,你就成功在Vue中引入了particles.js,并使用了particles.json配置文件。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [particles.js在vue中的实战用法](https://blog.csdn.net/weixin_44251396/article/details/103852212)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [particles.js在vue上的运用](https://blog.csdn.net/qq_36838191/article/details/98476006)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文