index.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. console.log("hello world");
  2. /**
  3. console.log(process.argv);
  4. process.argv.forEach(item => {
  5. console.log(item);
  6. });
  7. console.log("dirname : "+__dirname);
  8. console.log("filename : "+__filename);
  9. **/
  10. console.log("----------------------------");
  11. const comm=require("./commonjs.js");
  12. comm.info();
  13. console.log("----------------------------");
  14. //import {esname,esfunc} from "./es.mjs"
  15. //es.func();
  16. console.log("----------------------------");
  17. console.log("<h3>this is node test string!!!</h3>");
  18. //const {createApp}=Vue;
  19. import {createApp } from 'vue';
  20. //import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js';
  21. //import { createApp } from './js/vue.esm-browser.js';
  22. //import { createApp } from './js/vue.global.js';
  23. //import { Home } from "./vue/Home.vue";
  24. import Home from "./vue/Home.vue";
  25. import test from "./vue/test.vue";
  26. import About from "./vue/About.vue";
  27. import i18n from "./i18n.js";
  28. import { useI18n } from 'vue-i18n';
  29. /**
  30. const { locale,t } = useI18n();
  31. console.log("----------------------------");
  32. const changelang = type => {
  33. console.log(locale);
  34. console.log("----------------------------");
  35. locale.value=type;
  36. }
  37. **/
  38. //import router from "./router.vue";
  39. import router from "./router.js";
  40. //console.log(createApp);
  41. //console.log(i18n);
  42. console.log(router);
  43. const app=createApp({
  44. template:'#my-app',
  45. // template:`<div v-html='info'>template</div>`,
  46. components:{
  47. Home,
  48. test,
  49. About
  50. },
  51. data(){
  52. return{
  53. info:`<span style='color:red; font-size:30px'>hello vue template</span>`,
  54. number:0,
  55. locale:null,
  56. options:[
  57. {
  58. value: 'Option1',
  59. label: 'Option1',
  60. },
  61. {
  62. value: 'Option2',
  63. label: 'Option2',
  64. },
  65. {
  66. value: 'Option3',
  67. label: 'Option3',
  68. },
  69. {
  70. value: 'Option4',
  71. label: 'Option4',
  72. },
  73. {
  74. value: 'Option5',
  75. label: 'Option5',
  76. },
  77. ]
  78. }
  79. },
  80. methods:{
  81. add(){
  82. this.number++;
  83. },
  84. changelang(type){
  85. console.log(locale);
  86. console.log("-----------changelang-----------------");
  87. locale.value=type;
  88. }
  89. },
  90. setup(){
  91. const { locale,t } = useI18n();
  92. console.log("-------get locale--------");
  93. console.log(locale);
  94. // this.locale=locale;
  95. // 在根文件直接使用locale需要绑定一个locale变量至浏览器对象Window
  96. // 否则无法让methods中的方法调用其中的变量(全局变量)
  97. // 如果封装在组件中,然后提供给父组件使用,则直接定义函数即可
  98. window.locale=locale;
  99. console.log("-------after get locale--------");
  100. }
  101. }).use(i18n).use(router).mount("#app");
  102. //Vue.createApp(app).mount("#app");
  103. console.log("end the vue template render");