SourceCode.vue 938 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <div>
  3. <h3>Java 源代码</h3>
  4. <prism language="java">{{ sourceCode }}</prism>
  5. </div>
  6. </template>
  7. <script>
  8. import Prism from 'vue-prism-component'
  9. import 'prismjs'
  10. import 'prismjs/themes/prism.css'
  11. import 'prismjs/components/prism-java'
  12. export default {
  13. name: 'SourceCode',
  14. components: {
  15. Prism
  16. },
  17. data () {
  18. return {
  19. sourceCode: `public class MyArray {
  20. MyArray next;
  21. char[] letters;
  22. int[][] nums;
  23. MyArray[][] refs;
  24. public static void main(String[] args) {
  25. MyArray a = new MyArray();
  26. a.next = new MyArray();
  27. a.letters = new char[10];
  28. a.nums = new int[4][5];
  29. a.nums[2][2] = 1;
  30. a.refs = new MyArray[3][3];
  31. a.refs[1][1] = new MyArray();
  32. }
  33. }
  34. `
  35. }
  36. }
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. pre {
  41. background: none;
  42. padding: 0;
  43. }
  44. code {
  45. background: none !important;
  46. box-shadow: none !important;
  47. }
  48. </style>