我一直在阅读有关 的npm 文档npm audit。
它应该返回类似这样的内容:
但它返回的是:
为什么我会得到不同的格式?
所有在线文档和教程都没有显示我所看到的内容,这使得我很难理解。
我在3个不同的终端上尝试过;Mac 终端、iTerm 和 Visual Studio Code 内的终端。都显示出同样的事情。
还检查了 npm 版本,它是最新的(8.0.0)。
我正在尝试使用Quasar q 文件选择器来显示个人资料图片。
我正在使用此答案中的代码,并根据我的需要对其进行了稍微调整。
但我的handleUpload功能从未被触发。
这是怎么回事?我该如何解决?
<template>
<div>
<q-file
v-model="image"
label="Pick one file"
filled
style="max-width: 300px"
@change="handleUpload"
/>
</div>
<div>
<q-img
:src="imageUrl"
spinner-color="white"
style="height: 140px; max-width: 150px"
/>
</div>
</template>
<script setup lang="ts">
import { ref, Ref } from 'vue';
const image: Ref<File | null> = ref(null);
const imageUrl = ref('');
const handleUpload = () => {
console.log('handleUpload is triggered');
if (image.value) {
imageUrl.value = URL.createObjectURL(image.value);
}
};
</script>
Run Code Online (Sandbox Code Playgroud) 我使用 Vue 3 和 TypeScript 以及脚本设置标签 ( <script setup lang="ts">.
我经常在可组合项中有一个引用,如下所示:
const composableMessage = ref<string | null>(null);
Run Code Online (Sandbox Code Playgroud)
它是一个字符串或数字或初始值为“空”的东西。我故意使用null而不是undefined定义“空”,因为我更喜欢它。
然后我有一个带有 prop 的子组件,如下所示:
defineProps({
messageProp: {
type: String,
required: false,
default: '',
},
});
Run Code Online (Sandbox Code Playgroud)
当在父组件中使用它时,如下所示:
import myComposable from '/src/composables/myComposable';
const { composableMessage } = myComposable();
<my-component :messageProp="composableMessage" />
Run Code Online (Sandbox Code Playgroud)
我在以下位置收到此 TypeScript 错误:messageProp:
Type 'string | null' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.ts(2322)
Run Code Online (Sandbox Code Playgroud)
如果我使用const …
我正在使用 Vue 3 + Vue Router 4 + TypeScript。
我正在尝试使用router.push(),但我不断收到控制台错误:Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'push')。
我究竟做错了什么?
更新:如果我运行console.log(router);它会返回undefined. 因此我认为这就是问题所在,但为什么会发生这种情况以及如何解决它?
这是我的router/index.ts代码:
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
const routes: Array<RouteRecordRaw> = [
{
path: "/",
name: "Welcome",
component: () =>
import(/* webpackChunkName: "Welcome" */ "../views/Welcome.vue"),
},
{
path: "/chatroom",
name: "Chatroom",
component: () =>
import(/* webpackChunkName: "Chatroom" */ "../views/ChatRoom.vue"),
},
];
const router = …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一些 Firebase Cloud Functions,并使用 npm 包camelcase-keys来转换 API 响应的键。
\n但每当使用导入的包时,我都会收到此错误:
\n\n\n错误:无法从源加载函数定义:无法\n从函数源生成清单:错误:默认的 Firebase\napp 已存在。这意味着您调用了initializeApp()超过\nonce一次,而没有提供应用程序名称作为第二个参数。在大多数\n情况下,您只需要调用一次initializeApp()。但如果您确实想要初始化多个应用程序,请将第二个参数传递给initializeApp(),以便为每个应用程序指定一个唯一的名称。
\n
这个错误对我来说很奇怪,因为我遵循此处的建议,并且仅admin.initializeApp()在函数入口点 ( )调用一次index.ts。
这是文件结构的样子,以及我正在使用的代码的副本。
\n我没有包含所有代码,而是只包含了显着部分(导入、导出和 admin.initializeApp)。让我知道此处粘贴的更多代码是否有帮助:
\nfunctions/\n\xe2\x94\x9c\xe2\x94\x80 src/\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 index.ts\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 dataForSeo.ts\nRun Code Online (Sandbox Code Playgroud)\n索引.ts
\nfunctions/\n\xe2\x94\x9c\xe2\x94\x80 src/\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 index.ts\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80 dataForSeo.ts\nRun Code Online (Sandbox Code Playgroud)\nSEO数据
\nimport \'source-map-support/register\';\nimport * as functions from \'firebase-functions\';\nimport * as admin from \'firebase-admin\';\nadmin.initializeApp();\n\nexport const sydneyFunctions = functions.region(\'australia-southeast1\');\nexport const db = admin.firestore();\n\nexport {\n dataForSeoSerpGoogleOrganicDailyEnqueue,\n dataForSeoSerpGoogleOrganicTask,\n dataForSeoSerpGoogleOrganicPostbackUrl,\n dataForSeoOnPageStartCrawl,\n dataForSeoOnPageEnqueuePingbackUrl,\n dataForSeoOnPageGetResultTask,\n} from \'./dataForSeo\';\n …Run Code Online (Sandbox Code Playgroud) 我需要在我正在构建的 WordPress 插件中实现批处理,因为其中一个功能需要大量处理时间(API 查询、图像下载、插入帖子等)。
动作调度器看起来是一个很好的解决方案,但我对如何实现它感到困惑。
我安装了该插件,自述文件说我可以使用各种功能,例如as_schedule_single_action( $timestamp, $hook, $args, $group )处理任务。
如何使用这样的函数对批量任务进行排队?
例如,我如何使用 Action Scheduler 将这些任务排队以在后台运行:
$lower_case_names = array('mary', 'bob', 'trent', 'bill', 'jane');
function make_names_uppercase ($lower_case_names) {
$upper_case_names = array();
foreach ($lower_case_names as $name) {
$upper_case_names[] = strtoupper($name);
}
return $upper_case_names;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试打开一个弹出窗口,执行一些操作,然后将消息发送回打开的窗口,以便我可以使用它发送的数据执行更多操作。
本质上,我正在调整此处概述的流程。
这是我在“打开窗口”上的代码。单击社交连接按钮时它会运行。该代码打开一个弹出窗口,并在打开的窗口上分配一个侦听器事件以接收来自弹出窗口的消息:
//Do the operation
let windowObjectReference = null;
let previousUrl = null;
const openSignInWindow = (url, name) => {
// remove any existing event listeners
window.removeEventListener('message', receiveMessage);
// window features
const strWindowFeatures =
'toolbar=no, menubar=no, width=600, height=700, top=100, left=100';
if (windowObjectReference === null || windowObjectReference.closed) {
/* if the pointer to the window object in memory does not exist
or if such pointer exists but the window was closed */
windowObjectReference = window.open(url, name, strWindowFeatures);
} …Run Code Online (Sandbox Code Playgroud) 我想在桌子旁边放 3 个 div。表格应该根据里面的内容进行扩展,并且 3 个 div 应该平均占据剩余的空闲空间。
我需要将 div 堆叠在移动视图上的桌子下方,如下所示......
Desktop:
[div-1] [div-2] [div-3] [table]
Mobile:
[table]
[div-1]
[div-2]
[div-3]
Run Code Online (Sandbox Code Playgroud)
我一直在尝试使用 Flex 来使其正常工作,但我无法使表格根据内部内容进行扩展。
我无法使用,td {white-space: nowrap;}因为在移动设备上它将文本推出屏幕一侧。我需要表格根据内部内容进行扩展,但不应将内容强制扩展到屏幕之外。它需要像平常一样在较小的屏幕上环绕。
这是我的工作示例:http://codepen.io/anon/pen/qadbkK ?editors=1100
Desktop:
[div-1] [div-2] [div-3] [table]
Mobile:
[table]
[div-1]
[div-2]
[div-3]
Run Code Online (Sandbox Code Playgroud)
/* Do this on tablet size and up */
@media (min-width: 481px) {
/* Main outer div of helper items AND subtotals */
.cart-collaterals {
display: inline-flex;
}
/* Outer div of helper items */
.cart-helper-outer {
order: …Run Code Online (Sandbox Code Playgroud)我正在尝试构建一个 WordPress 函数,该函数接受图像 URL、下载图像、将其上传到媒体库并返回图像 ID。
我适应从这个答案这是从这里取的,我加wp_insert_attachment()结尾。
目前它不起作用,因为它不返回任何内容或上传任何媒体。
我通过逐步调试厌倦了调试var_dump(),我发现$url参数被正确传递,但没有任何输出download_url。
你知道有什么问题吗?
你能看到函数中还有什么可能被破坏的吗?
/* Add image to media library from URL and return the new image ID */
function bg_image_upload($url) {
// Gives us access to the download_url() and wp_handle_sideload() functions
require_once( ABSPATH . 'wp-admin/includes/file.php' );
// Download file to temp dir
$timeout_seconds = 10;
$temp_file = download_url( $url, $timeout_seconds );
if ( !is_wp_error( $temp_file ) ) {
// Array based …Run Code Online (Sandbox Code Playgroud) 我在我的 Vue / Firebase 应用程序上设置了 App Check。
为了使用 App Check 进行本地开发,我按照此处的说明进行操作。
这些说明要求您设置调试令牌,如下所示:
self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;
initializeAppCheck(app, { /* App Check options */ });
Run Code Online (Sandbox Code Playgroud)
但我的应用程序是用 TypeScript 编写的,它给了我这个 TypeScript 错误:
TS2339: Property 'FIREBASE_APPCHECK_DEBUG_TOKEN' does not exist on type 'Window & typeof globalThis'.
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
typescript ×5
firebase ×2
vue.js ×2
vuejs3 ×2
wordpress ×2
css ×1
html ×1
javascript ×1
npm ×1
npm-audit ×1
php ×1
popupwindow ×1
vue-router ×1