小编Mik*_*ink的帖子

Vue 3 模板根只需要一个 element.eslint-plugin-vue

在搭建一个 Vue 3 项目后,我注意到我的 App.vue 中有一个错误。

A functional component that renders the matched component for the given path. Components rendered in can also contain its own , which will render components for nested paths.

API Reference

[vue/no-multiple-template-root]
The template root requires exactly one element.eslint-plugin-vue
Run Code Online (Sandbox Code Playgroud)

我试过放

    "vue/no-multiple-template-root": 0
Run Code Online (Sandbox Code Playgroud)

在我的 .eslintrc.js

但错误仍然存​​在。我怎样才能摆脱错误?因为在 Vue 3 中,模板中不必只有一个元素。

module.exports = {
    root: true,
    env: {
        node: true
    },
    extends: [
        "plugin:vue/vue3-essential",
        "eslint:recommended",
        "@vue/typescript/recommended",
        "@vue/prettier",
        "@vue/prettier/@typescript-eslint"
    ],
    parserOptions: {
        ecmaVersion: 2020
    },
    rules: {
        "no-console": process.env.NODE_ENV …
Run Code Online (Sandbox Code Playgroud)

typescript vuejs3

12
推荐指数
6
解决办法
1万
查看次数

Typescript - 如何将 png 文件导入到我的 Typescript 文件中?

我使用 Parcel 编译器建立了自己的打字稿项目,并让所有内容都在内置服务器上运行。我实现了 pixi.js 并希望将 .png 文件导入到我的 .ts 文件中。但是当我尝试导入时,它说找不到该模块,即使这两个文件位于同一文件夹中?我缺少什么?

在此输入图像描述

在此输入图像描述

我尝试执行以下操作

npm install @types/node --save-dev
Run Code Online (Sandbox Code Playgroud)

tsconfig.json(位于我的根文件夹中)

{
  "compilerOptions": {
    "types": ["node"],
    "typeRoots": ["node_modules/@types"]
  }
}
Run Code Online (Sandbox Code Playgroud)

parcel typescript type-definition

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

如何在 vscode 中使用 ssh 克隆私有 git 存储库?

我使用的是 mac,我想知道如何使用 vscode 通过 ssh 克隆私有 github 存储库?我查看了 code.visualstudio.com/docs/editor/versioncontrol 但找不到任何有关使用 ssh 克隆的信息。

在 vscode 中,我转到左侧的源代码管理图标,然后单击克隆存储库。我进去了git@github.com:username/project,它说权限被拒绝。我确实生成了公钥和私钥,但在哪里输入它们?

git ssh github visual-studio-code

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

有没有办法为输入装饰前缀图标设置主题?

我有一个带有前缀 Icon 的输入字段,但我似乎无法弄清楚如何在未选择该字段时设置主题。这是未选中时的样子

在此处输入图片说明

如您所见,图标具有深色,而它应该具有边框的浅色。当我选择该字段时,我得到了这个

在此处输入图片说明

哪个好得多,因为现在我实际上可以看到图标了。文档说

The size and color of the prefix icon is configured automatically using an [IconTheme] and therefore does not need to be explicitly given in the icon widget.
Run Code Online (Sandbox Code Playgroud)

但是当我设置图标主题时

iconTheme: IconThemeData(color: _primaryColorLight),
primaryIconTheme: IconThemeData(color: _primaryColorLight),
accentIconTheme: IconThemeData(color: _primaryColorLight),
Run Code Online (Sandbox Code Playgroud)

没有什么改变?

  Widget _buildNameField(BuildContext context) {
    final ThemeData theme = Theme.of(context);
    return TextFormField(
      onSaved: (String value) => _phoneNumber = value,
      keyboardType: TextInputType.text,
      style: theme.textTheme.body1,
      decoration: InputDecoration(
        prefixIcon: Icon(Icons.person),
        hintText: 'Name',
      ),
      validator: (String value) {
        if (value.isEmpty || value.length …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

如何在 vscode 工作区中禁用 vetur linting?

我有一个 VS code 工作区,Vetur 抛出错误,因为我的 Vue 文件夹不在根目录,所以它认为它是一个 Vue 2 项目。如何禁用 Vetur linting?

我将其添加到我的 .vscode/settings.json

{
    "vetur.validation.template": false,
    "vetur.validation.script": false,
    "vetur.validation.style": false,
}
Run Code Online (Sandbox Code Playgroud)

如文档中所述

https://vuejs.github.io/vetur/linting-error.html#error-checking
Run Code Online (Sandbox Code Playgroud)

但它传达了这样的信息

This setting cannot be applied in this workspace. It will be applied when you open the containing workspace folder directly.
Run Code Online (Sandbox Code Playgroud)

这有点违背了目的

workspace vue.js visual-studio-code

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

WidgetsBindingObserver 是否可以在无状态小部件上工作?

我正在尝试使用 WidgetsBindingObserver 来查看我的应用程序是否被带到前台。但似乎并没有什么作用。它只适用于有状态的小部件吗?

class TheHomeView extends StatelessWidget with WidgetsBindingObserver {

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    print('lifecycle changed');
    if (state == AppLifecycleState.resumed) {
      print('resumed');
      showLatestGroupNotification();
    }
  }
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

为什么我的调用堆栈显示我有 2 个电源正在运行?

我开始为 FCM 实现后台消息,他们要求我制作自己的 Kotlin 应用程序。但自从我这样做以来,我的调用堆栈中似乎有 2 个主要函数。

在此输入图像描述

这怎么可能?如果我运行一个空项目,它的调用堆栈中有 0 个电源吗?

我添加了Application.kt

package HERE_I_HAVE_MY_PACKAGE_NAME

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService

public class Application: FlutterApplication(), PluginRegistrantCallback {
  override fun onCreate() {
    super.onCreate()
    FlutterFirebaseMessagingService.setPluginRegistrant(this)
  }

  override fun registerWith(registry: PluginRegistry) {
    FirebaseCloudMessagingPluginRegistrant.registerWith(registry)
  }
}
Run Code Online (Sandbox Code Playgroud)

和 FirebaseCloudMessagingPluginRegistrant.kt

package HERE_I_HAVE_MY_PACKAGE_NAME

import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin

class FirebaseCloudMessagingPluginRegistrant {
  companion object {
    fun registerWith(registry: PluginRegistry) {
      if (alreadyRegisteredWith(registry)) {
        return;
      }
      FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
    }

    fun alreadyRegisteredWith(registry: PluginRegistry): Boolean {
      val key = FirebaseCloudMessagingPluginRegistrant::class.java.name
      if (registry.hasPlugin(key)) {
        return …
Run Code Online (Sandbox Code Playgroud)

android dart kotlin flutter firebase-cloud-messaging

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

java.lang.NullPointerException:尝试调用虚拟方法“android.content.pm.PackageManager”

介绍

\n

我正在运行 flutter v1.17.5 DeviceApps v1.0.10 和 SystemAlertWindow v0.2.2+3 (有意不是最新版本)。我想从在前台运行的系统警报窗口打开我的应用程序,即使应用程序已关闭。

\n

我正在使用SystemOverlayWindow插件,该插件是一个 Activity SystemAlertWindowPlugin.java

\n

在我的Application.kt中,我注册插件并传递注册表

\n
public class Application: FlutterApplication(), PluginRegistrantCallback {\n\n   override fun onCreate() {\n     super.onCreate();\n     FlutterFirebaseMessagingService.setPluginRegistrant(this);\n     SystemAlertWindowPlugin.setPluginRegistrant(this);\n     createNotificationChannels();\n     FlutterMain.startInitialization(this);\n   }\n\n   override fun registerWith(registry: PluginRegistry?) {\n    if (!registry!!.hasPlugin("io.flutter.plugins.firebasemessaging")) {\n      FirebaseMessagingPlugin.registerWith(registry!!.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));\n    }\n    if (!registry!!.hasPlugin("in.jvapps.system_alert_window")) {\n      SystemAlertWindowPlugin.registerWith(registry!!.registrarFor("in.jvapps.system_alert_window"));\n    }\n    if (!registry!!.hasPlugin("fr.g123k.deviceapps")) {\n      DeviceAppsPlugin.registerWith(registry!!.registrarFor("fr.g123k.deviceapps"));\n    }\n   }\n
Run Code Online (Sandbox Code Playgroud)\n

我还注册了另一个名为DeviceApps的插件。这是DeviceAppsPlugin DeviceAppsPlugin.java

\n

问题

\n

简而言之

\n

因此,系统覆盖层(在前台运行)调用 > dart 回调 > 调用 DeviceApps 插件的方法 > 发生错误

\n …

java android android-activity dart flutter

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

如何使用 CLI 查看当前登录的 Firebase 帐户?

使用 firebase CLI 如何查看当前登录的 firebase 帐户?我查看了命令列表,但找不到它的命令。这是故意的吗?

firebase-cli

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

使用 Bootstrap 5 的最小宽度是什么类?

我查看了 Bootstrap 5 的文档,但我似乎找不到使用像素的最小宽度类?有没有?

https://v5.getbootstrap.com/docs/5.0/utilities/sizing/

bootstrap-5

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