小编djc*_*114的帖子

Vue 组合 API 中的只读目标

我的“Generateur”组件正在向我的“Visionneuse”组件发送道具。浏览器中一切正常,但我在控制台中看到以下消息:

\n
Set operation on key "texteEnvoye" failed: target is readonly.\n
Run Code Online (Sandbox Code Playgroud)\n

我真的不知道为什么会收到此消息,因为我将道具传递给了引用。\n这是我的组件:\n“Generateur”

\n
<template>\n  <div>\n    <h1>G\xc3\xa9n\xc3\xa9ration d'une carte de voeux</h1>\n    <div class="board">\n      <Visionneuse :texteEnvoye="texte" :taille="0.5"/>\n    </div>\n    <textarea\n      :style="'width: 60%; resize:none;height: 100px;'"\n      v-model="texte"\n      placeholder="\xc3\x89crivez votre texte ici">\n    </textarea>\n  </div>\n  <div>\n    <button\n      v-if="lien.length == 0"\n      id="boutonObtenirLien"\n      v-bind:class="{ enCours: lienEnCours }"\n      class="btn first"\n      @click="obtenirLien">Obtenir le lien</button>\n    <p\n      v-if="lien.length > 0">\n      Votre carte de voeux est accessible au lien suivant:<br/>\n      <a :href="lien">{{ lien }}</a>\n    </p>\n  </div>\n</template>\n\n<script>\nimport Visionneuse from '@/components/Visionneuse.vue';\n\nimport axios from 'axios';\n\nimport {\n …
Run Code Online (Sandbox Code Playgroud)

vue.js vue-reactivity vue-props vuejs3 vue-composition-api

13
推荐指数
2
解决办法
2万
查看次数

Vuetify v-file-input“onchange”工作但没有得到事件

请看下面我的代码。我的input工作正常,但不是v-file-input

<v-file-input
  accept=".json"
  ref="loadedFile"
  label="Upload file"
  @change="checkJSON"
  ></v-file-input>

<input
    type="file"
    accept=".json"
    @change="checkJSON"
    >



methods: {
  checkJSON: function(e) {
    console.log("JSON checking")
    console.log(JSON.stringify(e))
    console.log(e.target.files)
    return
  }
}
Run Code Online (Sandbox Code Playgroud)

控制台显示 的文件input,但这是我收到的消息v-file-input

[Vue warn]: Error in v-on handler: "TypeError: e.target is undefined"
Run Code Online (Sandbox Code Playgroud)

这是正常的吗?我想使用 vuetify 组件,它更漂亮。提前致谢。

vue.js vuetify.js

4
推荐指数
1
解决办法
2491
查看次数

在 VueJS 3 中全局使用 momentJS

在 VueJS 2 中,我可以像这样全局使用 momentJS:

main.js

import moment from 'moment';
moment.locale('fr');
Object.defineProperty(Vue.prototype, '$moment', { value: moment });
Run Code Online (Sandbox Code Playgroud)

在任何组件中:

{{ item.date_creation?$moment(item.date_creation).format('l'):'No date'}}
Run Code Online (Sandbox Code Playgroud)

在 VueJS 3 中,我尝试在 main.js 中执行以下操作:

import { createApp } from 'vue';
import moment from 'moment';
import App from './App.vue';
import './registerServiceWorker';
import router from './router';
import store from './store';

moment.locale('fr');

createApp(App).use(moment).use(store).use(router)
  .mount('#app');
Run Code Online (Sandbox Code Playgroud)

但实际上我不能在我的任何组件中使用“时刻”,我必须在每个组件中导入“时刻”。难道就没有更好的解决办法吗?我读了很多文档和教程,但没有看到任何好的东西......提前致谢。

编辑:这是我在组件中使用 $moment 的方式:

<template>
  <div class="xx" :key="'title-'+myReactiveVariable.title">
    <h1>{{ myReactiveVariable.title }}</h1>
    <div class="yy">
      {{ myReactiveVariable.content }}
    </div>
    <footer>
      Sent on
      {{ myReactiveVariable.date }}
      by …
Run Code Online (Sandbox Code Playgroud)

javascript momentjs vue.js vuex vuejs3

3
推荐指数
1
解决办法
9683
查看次数

安装时未请求 Android 权限

我在这里发帖之前搜索过类似的问题,但没有找到解决我问题的答案。我的 manifest.xml 文件似乎是正确的,我希望用户被要求获得安装权限(不是运行时,它已经可以与我的代码一起使用)。我不知道为什么我放的参数不起作用:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:name="VILES" android:versionCode="1" android:versionName="0.0.1" package="fr.nc.delegue.referendum" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-feature android:name="android.hardware.telephony" android:required="false" />
    <uses-permission android:name="android.permission.RECEIVE_WAP_PUSH" />
    <uses-permission android:name="android.permission.RECEIVE_MMS" />
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
</manifest>
Run Code Online (Sandbox Code Playgroud)

我使用 Cordova(和 Quasar)来构建我的应用程序,该应用程序运行良好,但我仍然遇到安装时没有请求权限的问题......任何人都可以告诉我我在这里做错了什么吗?提前致谢 :)

android android-manifest cordova android-permissions

1
推荐指数
1
解决办法
264
查看次数

ThreeJS 组件在 VueJS 2 但不是 3 中工作

我正在将我的应用程序升级到 VueJS 3。我读到您可以保留相同的组件。但是我现在在控制台中有一个错误,尽管我没有改变任何东西。这是我的组件:

<template>
  <v-container>
    <div
      @click="onClick"
      @mousemove="onMouseMove"
      id="menu3D"
      style="background-color: transparent; position: fixed; left: 20px; width:15%; height:100%;">
    </div>
    <v-row class="text-center">

      <v-col
        class="mb-5"
        cols="12"
      >
        <h2 class="headline font-weight-bold mb-3">
          Accueil
        </h2>

        <v-row justify="center">

          <p>
            Client: {{ JSON.stringify(client)}}
          </p>
          <p>
            Mouse: {{ JSON.stringify(mouse)}}
          </p>
          <p>
            Container: {{ JSON.stringify(container)}}
          </p>
        </v-row>
      </v-col>
    </v-row>
  </v-container>
</template>

<script>

import * as Three from 'three';

export default {
  name: 'Accueil',
  mounted() {
    this.init();
  },
  methods: {
    init() {
      this.createScene();
      this.createCamera();
      this.userData.formes.forEach((x) => this.createShape(x));
      this.addSpotlight(16777215);
      this.addAmbientLight();
      this.animate(); …
Run Code Online (Sandbox Code Playgroud)

three.js vue.js vuejs2 vuejs3

1
推荐指数
2
解决办法
893
查看次数

在 Vue Router 中有条件地导入一个组件

我想有条件地在 vue 路由器中导入一个组件。这是我目前所拥有的:

children: [
  {
    path: ':option',
    component: () => import('../components/Option1.vue'),
  },
],
Run Code Online (Sandbox Code Playgroud)

根据什么:option是我想要导入一个不同的组件(Option1.vueOption2.vue,等)。我知道我可以放几个,children但我实际上需要option在我的父组件中使用该变量(如果路由有选项,我会进行测试)。

怎么可能做到这一点?提前致谢 :)

vue.js vue-router vuejs3

1
推荐指数
1
解决办法
743
查看次数