访问json得到pdf文件信息

This commit is contained in:
zhbaor 2021-11-02 02:16:27 +08:00
parent 38b6a3bd57
commit 6de7a8bae7
6 changed files with 36 additions and 11 deletions

View file

@ -29,13 +29,22 @@
<td>{{ file }}</td>
<td class="text-center">
<a
:href="`${url_root}pdfjs/web/viewer.html?file=${url_root}${file}`"
:href="
url_root +
'pdfjs/web/viewer.html?file=' +
url_root +
category.name +
'/' +
file
"
target="_blank"
><i class="bi bi-book"></i
></a>
</td>
<td class="text-center">
<a :href="`${url_root}${file}`"><i class="bi bi-cloud-download"></i></a>
<a :href="`${url_root}${category.name}/${file}`"
><i class="bi bi-cloud-download"></i
></a>
</td>
</tr>
</tbody>
@ -53,20 +62,19 @@
<script lang="ts">
import { defineComponent } from 'vue';
import axios from 'axios';
export default defineComponent({
name: 'App',
data() {
return {
// url_root: '/~lixiangyu/',
url_root: '/',
categories: [
{
name: 'Computer',
files: ['modern-full-stack.pdf', 'gdb.pdf'],
},
],
url_root: process.env.VUE_APP_URL_ROOT,
categories: [],
};
},
async created() {
const { data } = await axios.get(`${this.url_root}db.json`);
this.categories = data.categories;
},
});
</script>