用oruga-next将VUE 2转换为VUE 3-可以使用o-switch的V模型,然后观看

发布于 2025-02-14 01:59:03 字数 1686 浏览 0 评论 0原文

我正在尝试将VUE 2的应用程序移植到VUE 3。我有问题。我不确定这些问题是模板中的“ V模型”,还是脚本区域中的“手表”命令。这是一个vue文件。

    <template>
      <div class="home notification is-primary">
        <o-field>

          <o-switch  v-model="isSwitched" >
            Audio: {{ isSwitched }} 
          </o-switch>
            </div>
    </template>

    <script>


    export default {
      name: "HomeInput",
      props: {
        setAudio: Function,
      },
      data() {
        return {
          isSwitched:true,
        };
      },
      methods: {
      },
      mounted: function () {
      },

      watch:  {
        'isSwitched' (val) {
            console.log(val,  "switch");
            this.setAudio(val);
        }
      },
    };
    </script>

    <style scoped>
    </style>

尽管我可以在屏幕上看到组件开关,但我永远不会在控制台中获得“开关”。以下是我的软件包的一部分。我将Oruga-UI用于“ O-Switch”之类的Vue组件。

  "dependencies": {
    "@babel/cli": "^7.18.6",
    "@babel/core": "^7.18.6",
    "@babel/preset-env": "^7.18.6",
    "@google-cloud/speech": "^4.10.0",
    "@oruga-ui/oruga-next": "^0.5.5",
    "@vue/babel-preset-app": "^5.0.7",
    "@vue/cli": "^5.0.7",
    "@vue/cli-plugin-babel": "^5.0.7",
    "@vue/cli-plugin-eslint": "^5.0.7",
    "@vue/cli-plugin-router": "^5.0.7",
    "@vue/cli-service": "^5.0.7",
    "@vue/compat": "^3.1.0-0",
    "babel-loader": "^8.2.5",
    "babel-preset-env": "^1.7.0",
    "browser-request": "^0.3.3",
    "browserify-fs": "^1.0.0",
    "bulma": "^0.9.4",
    "vue": "^3.2.37",
    "vue-loader": "^17.0.0",
    "vue-router": "^4.1.1",
    "webpack": "^5.73.0",
    "webpack-cli": "^4.10.0"
  },

I am trying to port an application from vue 2 to vue 3. I have problems. I'm not sure if the problems are the 'v-model' in the template, or the 'watch' command in the script area. This is a vue file.

    <template>
      <div class="home notification is-primary">
        <o-field>

          <o-switch  v-model="isSwitched" >
            Audio: {{ isSwitched }} 
          </o-switch>
            </div>
    </template>

    <script>


    export default {
      name: "HomeInput",
      props: {
        setAudio: Function,
      },
      data() {
        return {
          isSwitched:true,
        };
      },
      methods: {
      },
      mounted: function () {
      },

      watch:  {
        'isSwitched' (val) {
            console.log(val,  "switch");
            this.setAudio(val);
        }
      },
    };
    </script>

    <style scoped>
    </style>

I never get 'switch' in the console, though I can see the component switch on the screen. Below is part of my package.json. I use oruga-ui for the vue components like 'o-switch'.

  "dependencies": {
    "@babel/cli": "^7.18.6",
    "@babel/core": "^7.18.6",
    "@babel/preset-env": "^7.18.6",
    "@google-cloud/speech": "^4.10.0",
    "@oruga-ui/oruga-next": "^0.5.5",
    "@vue/babel-preset-app": "^5.0.7",
    "@vue/cli": "^5.0.7",
    "@vue/cli-plugin-babel": "^5.0.7",
    "@vue/cli-plugin-eslint": "^5.0.7",
    "@vue/cli-plugin-router": "^5.0.7",
    "@vue/cli-service": "^5.0.7",
    "@vue/compat": "^3.1.0-0",
    "babel-loader": "^8.2.5",
    "babel-preset-env": "^1.7.0",
    "browser-request": "^0.3.3",
    "browserify-fs": "^1.0.0",
    "bulma": "^0.9.4",
    "vue": "^3.2.37",
    "vue-loader": "^17.0.0",
    "vue-router": "^4.1.1",
    "webpack": "^5.73.0",
    "webpack-cli": "^4.10.0"
  },

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文