如何在Nuxt(或Vue)中以字符串形式从文本文件中读取内容?

vuejs2 Vue.js

梅GO

2020-03-27

我想读取一个文本文件的内容,该文件已导入到我的.vue文件中,例如import ToS from '~/static/terms-of-service.txt';

我想以字符串形式访问内容。

我该怎么做?

第3815篇《如何在Nuxt(或Vue)中以字符串形式从文本文件中读取内容?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
番长樱梅 2020.03.27

我最终使用了https://github.com/webpack-contrib/raw-loader

似乎您需要加载程序才能读取Vue中的文件

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android