Advertisement
claukiller

vue

Mar 14th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. <template>
  2. <div>
  3. <div class="row">
  4. <a href="add.html"> añadir archivo </a>
  5. </div>
  6. <div class="row col-xs-2">
  7. <p>{{msg}}</p>
  8. <ul>
  9. <li :key="file.webViewLink" v-for="file of files">
  10. <p><strong>{{file.title}}</strong></p>
  11. <a :href="file.webViewLink">
  12. <img :src="chooseExtension(file.extension)" style="width: 20%">
  13. {{file.filename}}.{{file.extension}}
  14. </a>
  15. </li>
  16. </ul>
  17.  
  18. </div>
  19. </div>
  20. </template>
  21.  
  22. <script>
  23. import axios from 'axios'
  24. export default {
  25. data () {
  26. return {
  27. msg: 'Welcome to Your Vue.js PWA',
  28. files: []
  29. }
  30. },
  31. created () {
  32. axios.get('http://localhost:9005/list')
  33. .then(response => {
  34. this.files = response.data
  35. })
  36. },
  37. methods: {
  38. chooseExtension (extension) {
  39. if (extension === 'txt') {
  40. return 'static/img/txt.jpg'
  41. }
  42. if (extension === 'pptx') {
  43. return 'static/img/ppt.jpg'
  44. }
  45. if (extension === 'docx') {
  46. return 'static/img/docx.jpg'
  47. }
  48. if (extension === 'pdf') {
  49. return 'static/img/pdf.jpg'
  50. }
  51. if (extension === 'xlsx') {
  52. return 'static/img/xlsx.jpg'
  53. }
  54. if (extension === 'zip') {
  55. return 'static/img/zip.jpg'
  56. }
  57. if (extension === 'jpg' || extension === 'png') {
  58. return 'static/img/img.png'
  59. }
  60. }
  61. }
  62. }
  63. </script>
  64.  
  65. <!-- Add "scoped" attribute to limit CSS to this component only -->
  66. <style>
  67.  
  68. h1, h2 {
  69. font-weight: normal;
  70. }
  71.  
  72. ul {
  73. list-style-type: none;
  74. padding: 0;
  75. }
  76.  
  77. li {
  78. display: inline-block;
  79. margin: 0 10px;
  80. }
  81.  
  82. a {
  83. color: #35495E;
  84. }
  85.  
  86. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement