这让我发疯了好几天。
我无法在android模拟器上运行我的应用程序:运行时react-native run-android,出现以下错误:
> Task :react-native-maps:compileDebugRenderscript FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':react-native-maps:debugCompileClasspath'.
> Could not resolve com.android.support:support-compat:26.1.0.
Required by:
project :react-native-maps
> Cannot find a version of 'com.android.support:support-compat' that satisfies the version constraints:
Dependency path 'theTKMapp:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.58.4' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-compat:28.0.0'
Dependency path 'theTKMapp:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.58.4' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-core-utils:28.0.0' --> 'com.android.support:support-compat:28.0.0'
Dependency path 'theTKMapp:react-native-maps:unspecified' --> 'com.facebook.react:react-native:0.58.4' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-fragment:28.0.0' --> 'com.android.support:support-compat:28.0.0'
Dependency …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个漂亮的线性渐变,在卡片图像的底部添加阴影。
我希望这张卡有圆角,但是当我应用 ShaderMask 时,线性渐变的底部是黑色的,它占据了容器的整个空间(即容器有圆角,但着色器的底部黑色部分)蒙版创建直角)。
看图片:
这是代码:
import 'package:flutter/material.dart';
import 'dart:math';
class ProfileCard extends StatelessWidget {
final String imageName;
final String title;
ProfileCard({this.imageName, this.title});
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
ShaderMask(
shaderCallback: (Rect bounds) {
return LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: <Color>[Colors.transparent, Colors.black],
).createShader(bounds);
},
blendMode: BlendMode.darken,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
image: DecorationImage(
image: AssetImage('assets/images/$imageName.jpg'),
fit: BoxFit.cover,
),
),
),
),
],
);
}
}
Run Code Online (Sandbox Code Playgroud)
左上角和右上角都可以,因为渐变的上端部分是透明的。
请注意,堆栈还有其他子级;我只是删除了它们以使代码更具可读性。我还尝试将堆栈包装在容器内并将 borderRadius 应用于该容器,但它不起作用。
如何同时在容器背景图像和圆角上拥有这种漂亮的渐变?
我写了这段代码:
if (file_exists("testfile.rtf")) echo "file exists.";
else echo "file doesn't exist.";
$fh = fopen("testfile.rtf", 'w') or die("impossible to open the file");
$text = <<< _END
Hi buddies,
I write for the first time
in a PHP file!
_END;
fwrite($fh, $text) or die("Impossible to write in the file");
fclose($fh);
echo ("writing in the file 'testfile.rtf' succeed.");
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,它说:
fopen(testfile.rtf):无法打开流:第64行/Applications/XAMPP/xamppfiles/htdocs/test/test1.php中的权限被拒绝无法打开文件
我在我的MAC上使用XAMPP在本地服务器上工作.
我找到了几个主题,其中一些人有同样的问题,并使用一个名为"chmod 777"的东西解决了它,但我不知道这意味着什么,在哪里写这个,等等.
我正在 Mac 上为 React Native 设置环境,我必须拥有以下环境变量:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Run Code Online (Sandbox Code Playgroud)
所以我的.bash_profile文件看起来像这样(见下文);恐怕PATH我的不同设置的变量定义会发生冲突。
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
# added by Anaconda3 4.3.0 installer
export PATH="//anaconda/bin:$PATH"
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for Flutter
export PATH = /Users/juliencorbin/flutter/bin:$PATH
# Setting path for Android home (react native tools)
export …Run Code Online (Sandbox Code Playgroud) 嘿,所以在我遇到一些问题后,我决定卸载 Postgres 并重新安装它(顺便说一下,重新安装较新的版本)。
我正在尝试访问 postgres 来为我的 Rails 应用程序创建一个新的数据库,所以我运行su postgres或su _postgres然后我被要求输入密码但我输入的任何内容都不起作用。
所以我尝试sudo -u postgres psql并得到
sudo: unknown user: postgres
sudo: unable to initialize policy plugin
Run Code Online (Sandbox Code Playgroud)
我还尝试禁用 SIP(请参阅:此处)
但它也不起作用。相同的结果。
我不知道该怎么办。任何的想法 ?我使用的是 Mac OS High Sierra 10.13.6。
我正在建立一个推荐系统,当用户创建一个帐户时,随机生成一个由六个字符组成的字符串.
为此,我使用gem uniquify:
class User < ApplicationRecord
uniquify :random_string, length: 6
end
Run Code Online (Sandbox Code Playgroud)
例如,它创建一个类似的字符串:"Ed3x7W".
即使它不太可能,我也想找到一种方法来100%确保每个创建的字符串都是唯一的.
实现这一目标的最佳方法是什么?
因此,我使用 axios 将我的reactJS 前端与我的rails API 后端链接起来。
这是我的路由器:
[...]
<Route path="/" component={LandingPage} exact={true}/>
<Route path="/meals" component={MealsPage} exact={true}/>
<Route exact path="/user/:token"
render={routeProps => (
<MyAccountPage {...routeProps} currentUser={this.state} />
)}
/>
[...]
Run Code Online (Sandbox Code Playgroud)
这是我使用 axios 的函数:
getCurrentUser: jwt => {
let config = {
headers: {}
}
if (jwt) {
config['headers']['Authorization'] = 'Bearer ' + jwt
}
return axios.get('api/v1/users/current', config)
.then(response => {
console.log(response)
return response.data
})
.catch(error => {
if( error.response ){
console.log(error: error.response.data);
}
return undefined
})
}
Run Code Online (Sandbox Code Playgroud)
/它与和路线完美配合/meals。但是,当 …