为啥现在又醒了呢,用vite2,刚才那个有什么问题?

news/2024/7/10 1:54:37 标签: vue
<template>
    <div id="app">
  <p>姓名: {{ name }}</p>
  <p>职业: {{ state.work }}</p>
  </div>
</template>

<script>
//import HelloWorld from './components/HelloWorld.vue'

//import { ref, reactive } from "vue";这两个都可以
import { createApp, ref, reactive } from "vue";
   export default {
     setup() {
       //const count = ref(0);
       const name = ref("Nick")
       //const object = reactive({ foo: "bar" });
       const state = reactive({ 
         work: "前端工程师" 
         });
      return {
        state,
        name,
      };
     },
   };
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

加一个也可以
在App.vue里面

<template>
    <div id="app">
  <p>姓名: {{ name }}</p>
  <p>职业: {{ state.work }}</p>
  <p>年龄: {{ state.age }}</p>
  </div>
</template>

<script>
//import HelloWorld from './components/HelloWorld.vue'

//import { ref, reactive } from "vue";
import { createApp, ref, reactive } from "vue";
   export default {
     setup() {
       //const count = ref(0);
       const name = ref("Nick")
       //const object = reactive({ foo: "bar" });
       const state = reactive({ 
         work: "前端工程师",
         age: "18",
         });
      return {
        state,
        name,
      };
     },
   };
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>


http://www.niftyadmin.cn/n/957730.html

相关文章

微信小程序 wxss设置height:100% 不起作用解决办法

问题&#xff1a;小程序设置背景图片高度适应整个屏幕&#xff0c;设置height 100% 不起作用&#xff1f; .content { height: 100%; } 解决办法&#xff1a;在上面添加一个page 样式就可以解决 page{ height: 100%; } .content { height: 100%; }

MySQL-按指定数据排序

MySQL-按 如果指定数据是一个&#xff0c;如id1要排在第一位 SELECT * FROM 表名 ORDER BY id<>1; 1 如果指定数据是多个&#xff0c;如id in (1,2,3) SELECT * FROM 表名 ORDER BY id NOT IN(1,2,3); 1 2 ———————————————— 版权声明&#xff1a;本…

为什么const App = { 不行,必须要export default { ,为什么vue要export default而html用const App且createApp.mounted

<template><title>陈尼克</title><div id"app"><p>姓名: {{ name }}</p><p>职业: {{ state.work }}</p></div> </template><script> //import { defineProps, reactive } from vueimport { creat…

springboot mysql serverTimezone url 设置时区

serverTimezone GMT即可 spring.datasource.urljdbc:mysql://127.0.0.1:3306/XXX?useUnicodetrue&characterEncodingutf8&serverTimezone GMT 1、概念&#xff1a; serverTimezone连接mysql数据库时指定了时差 2、时区示例&#xff1a; //北京时间东八区 serve…

python topN 取 最大的N个数 或 最小的N个数

import numpy as np a np.array([1,4,3,5,2]) b np.argsort(a) print(b) print结果[0 4 2 1 3] 说明a[0]最小&#xff0c;a[3]最大 a[0]<a[4]<a[2]<a[1]<a[3] 这里要借助到python的内置模块heapq&#xff0c;其原理是基于堆的&#xff0c;也就是二叉树 i…

这样写之出来一个0,没有出来bar

<template><title>陈尼克</title><div id"app">{{ count }} {{ object.foo }}</div> </template><script> //import { defineProps, reactive } from vueimport { createApp, ref, reactive } from vue; //const { create…

【SpringBoot实战】分布式定时任务锁Shedlock

在我们业务开发过程中&#xff0c;经常会有需求做一些定时任务&#xff0c;但是由于定时任务的特殊性&#xff0c;以及一些方法的幂等性要求&#xff0c;在分布式多节点部署的情况下&#xff0c;某个定时任务只需要执行一次。 1. 背景介绍 ShedLock(https://github.com/lukas…

怎么改成1 foo呢?

改得不对 <template><title>陈尼克</title><div id"app">{{ count }} {{ object.foo }}</div> </template><script> //import { defineProps, reactive } from vueimport { createApp, ref, reactive } from vue; //cons…