我正在使用 macOS Mojave,当我尝试使用 gem 安装 cocoapods 时,出现以下错误。
构建原生扩展。这可能需要一段时间... 错误:安装 cocoapods 时出错:错误:无法构建 gem 本机扩展。
Run Code Online (Sandbox Code Playgroud)current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200302-707-1iveybq.rb extconf.rb mkmf.rb 在 /System/Library 找不到 ruby 的头文件/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf 失败,退出代码 1
Gem 文件将保留安装在 /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 中以供检查。结果记录到 /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out
当我运行以下命令时会出现此错误。
sudo gem install cocoapods
sudo gem install -n /usr/local/bin cocoapods
Run Code Online (Sandbox Code Playgroud)
我已经安装了 xcode 命令行工具,运行时收到以下消息 xcode-select --install
xcode-select: 错误:命令行工具已经安装,使用“软件更新”安装更新
我也同意 xcode 许可协议与命令 sudo xcodebuild -license
错误登录/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out
给出了以下内容
当前目录:/Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteco $ mkmf.rb 在 /System/Library/Frameworks/Ruby.fra$ 找不到 ruby 的头文件
extconf 失败,退出代码 1
我该怎么做才能解决这个问题?
我有一个捐款表如下。
捐款表
| id| amount | member_id |
|---|--------|-----------|
| 0 | 500 | 01|
| 1 | 1000 | 02|
| 2 | 2000 | 01|
Run Code Online (Sandbox Code Playgroud)
如何按成员 id 查找 sum 和分组表,如下所示。
| amount | member_id |
|--------|-----------|
| 2500 | 01|
| 1000 | 02|
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码,但似乎不起作用。
const salesValue = await DONATIONS.sum('amount', {
group: 'member_id'
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习如何使用three js
React。为此,我正在使用@react-three/fiber
和@react-three/drei
。
chriscourses 的这个项目是我用来学习三个 js 的项目,我希望用它来学习使用 Threejs 和 React。
下面的代码应该显示从给定坐标中萌芽的方框,但目前它们都向一个方向倾斜。使用lookat
应该可以解决问题,但是我不知道如何lookat
在@react-three/fiber
/中使用@react-three/drei
。
import React, { FC, useRef } from 'react';
import { Box as NativeBox } from '@react-three/drei'
import { Vector3 } from 'three';
import { useFrame } from '@react-three/fiber';
type Props = {
country: any,
}
const lookAtCubePosition = new Vector3(0, 0, 0)
const Box: FC<Props> = (props) => {
const mesh = useRef()
const { …
Run Code Online (Sandbox Code Playgroud) I am very new to Dart/Flutter and I have a confusion regarding the => notation. The documentation says that the => notation is used as a shorthand to return a single expression.
bool isNoble(int atomicNumber) => _nobleGases[atomicNumber] != null;
My doubt comes when I am trying to set state in a flutter application.
RaisedButton(
onPressed: () => {
setState(() {
print('hello');
_products.add('More stuff');
})
},
child: Text('Add Product'),
),
Run Code Online (Sandbox Code Playgroud)
Now when i change the setState method with => notation
RaisedButton( …
Run Code Online (Sandbox Code Playgroud) 我有一个普通的 next js 应用程序,在我的 package.json 文件中包含以下脚本。
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start -p 3002"
},
Run Code Online (Sandbox Code Playgroud)
我有一个带有标签的启动脚本,-p
用于在端口 3002 上启动应用程序。
pm2
我希望使用以下脚本运行该应用程序。
PORT=3002 NODE_PORT=3002 pm2 start npm --name "nextjs-website" -- start
Run Code Online (Sandbox Code Playgroud)
使用环境变量 PORT 和 NODE_PORT 不起作用。如何使用 package.json 文件中提到的相同端口启动此应用程序。
start
另外,是否可以在 package.json 文件中运行 pm2 服务?
我目前有一个由JsBarcode的react实现生成的画布条形码,称为react-barcode。目前,我可以右键单击画布,然后在新选项卡中将其作为图像打开。如何通过单击按钮来实现此功能?
我已经检查了这个问题的几个答案,但他们都使用jquery。我正在寻找使用React或纯js的实现。
我尝试使用如下方式提取参数useRoute
。
const route = useRoute();
const { params } = route;
const {
id, name,
} = params;
Run Code Online (Sandbox Code Playgroud)
一切正常,但 linter 突出显示id
并name
出现以下错误。
属性“id”在类型“object | ”上不存在 不明确的
我该如何克服这个问题。
typescript reactjs react-native react-navigation react-navigation-v5
我正在尝试使用弹性框创建滑块。我的想法是创建一个父容器并使滑块水平溢出。然后将父元素设置为没有溢出,以便隐藏溢出的子元素,我们可以使用滚动条查看其他子元素。
.slider-container {
width: inherit;
height: 40em;
overflow: hidden;
margin-bottom: 1000px;
}
.slider {
display: flex;
flex-direction: row;
overflow-x: scroll;
height: inherit;
}
.slide {
height: inherit;
}
.x {
background-color: green;
}
.y {
background-color: red;
}
.z {
background-color: blue;
}
Run Code Online (Sandbox Code Playgroud)
<div class="slider-container">
<div class="slider">
<div class="x">XXXXX</div>
<div class="y">YYYYY</div>
<div class="z">ZZZZZ</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
下图显示了我现在得到的输出。我正在尝试使三个 div 具有父容器的全宽。这样,只有红色 div 应该是可见的,而它占据了父 div 的空间。要查看其余的 div,我们必须向右滚动。
我曾尝试将宽度设置为 100%,但似乎不起作用。
我有一个函数,可以在循环内对数据库进行两个异步调用。问题是返回函数在从循环中检索数据之前起作用。
const myFunc = async (customers) => {
const customerList = customers.map(async (customer) => {
const cashCollected = await knex('cash_collections')
.sum('amount_collected as amount')
.where('account_code', customer.code)
.first();
const orderValue = await knex('orders')
.sum('discounted_price as amount')
.where('customer_id', customer.id)
.first();
const customerData = {
name: customer.name,
outstandingBalance: (orderValue.amount - cashCollected.amount),
};
// This line works after console.log(customerList);
console.log(customerData);
return customerData;
});
// console and return works before data is retrieved
// (before console.log(customerData) is run)
console.log(customerList);
return customerList;
};
// Function is called …
Run Code Online (Sandbox Code Playgroud) 我有两组表格,如下所示
用户表
| id| name |
|----|------|
| 1 | x |
| 2 | y |
| 3 | z |
Run Code Online (Sandbox Code Playgroud)
访问表
| event_id | user_id |
|----------|---------|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 1 |
| 5 | 1 |
| 1 | 2 |
Run Code Online (Sandbox Code Playgroud)
如何获取每个用户的访问次数以及用户名。我知道原始 SQL 可以与 knex 一起使用,并且我可以通过 SQL 查询轻松地做到这一点。我很想知道仅使用 knex js 是否可以实现这一点。
await knex('visits').count().groupBy('user_id');
Run Code Online (Sandbox Code Playgroud)
上面的查询将为我提供每个用户的访问次数。如何在同一查询中获取用户名。
我正在寻找如下所示的输出
| user_id | name | count | …
Run Code Online (Sandbox Code Playgroud) node.js ×3
reactjs ×3
javascript ×2
knex.js ×2
mysql ×2
async-await ×1
css ×1
dart ×1
database ×1
flexbox ×1
flutter ×1
html ×1
ios ×1
jsbarcode ×1
macos ×1
next.js ×1
pm2 ×1
react-native ×1
rubygems ×1
sequelize.js ×1
service ×1
three.js ×1
typescript ×1
xcode ×1