我为自己缺乏知识而道歉.我想在文件中导入一个const值.我在同一目录中有两个文件Home.js和styles.js.
Home.js
import React from 'react';
import styles from './styles';
const Home = (props) => {
const HEADER_MAX_HEIGHT = 200;
}
export { HEADER_MAX_HEIGHT };
export default Home;
Run Code Online (Sandbox Code Playgroud)
并在styles.js
import { StyleSheet } from 'react-native'
import { HEADER_MAX_HEIGHT } from './Home';
export default StyleSheet.create({
header: {
height: HEADER_MAX_HEIGHT
}
});
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误
找不到变量:HEADER_MAX_HEIGHT
我怎样才能在styles.js中访问该变量?
在laravel docs中,似乎有一个整数和一个数字验证规则.我想知道两者之间有什么区别?
嗨,我在运行gulp手表时遇到此错误.我在laravel项目中使用vueify.为什么会发生这种情况.这些天它一直很好,今天就来了.
$ gulp watch
[12:56:01] Using gulpfile ~/Documents/web_projects/next-home/gulpfile.js
[12:56:01] Starting 'watch'...
[12:56:01] Starting 'browserify'...
Fetching Browserify Source Files...
- resources/assets/js/app.js
Saving To...
- public/js/app.js
[12:56:02] Finished 'browserify' after 707 ms
[12:56:02] 'watch' errored after 722 ms
[12:56:02] Error: watch /home/bazi/Documents/web_projects/next-home/resources/assets/less/ ENOSPC
at exports._errnoException (util.js:893:11)
at FSWatcher.start (fs.js:1313:19)
at Object.fs.watch (fs.js:1341:11)
at Gaze._watchDir (/home/bazi/Documents/web_projects/next-home/node_modules/gaze/lib/gaze.js:289:30)
at /home/bazi/Documents/web_projects/next-home/node_modules/gaze/lib/gaze.js:358:10
at iterate (/home/bazi/Documents/web_projects/next-home/node_modules/gaze/lib/helper.js:52:5)
at Object.forEachSeries (/home/bazi/Documents/web_projects/next-home/node_modules/gaze/lib/helper.js:66:3)
at Gaze._initWatched (/home/bazi/Documents/web_projects/next-home/node_modules/gaze/lib/gaze.js:354:10)
at Gaze.add (/home/bazi/Documents/web_projects/next-home/node_modules/gaze/lib/gaze.js:177:8)
at new Gaze (/home/bazi/Documents/web_projects/next-home/node_modules/gaze/lib/gaze.js:74:10)
events.js:154
throw er; // Unhandled 'error' event …Run Code Online (Sandbox Code Playgroud) 我有这个不是ES6的反应组件class.这是一个const像:
import React from 'react';
import Dashboard from './components/Dashboard';
const Home = (props) => {
const componentDidMount = () => {
console.log('component mounted'); // not working
}
return <Dashboard />;
}
Run Code Online (Sandbox Code Playgroud)
在这个const里面我如何定义componentDidMount函数就像我在普通的ES6中那样做class?这就是我以前做过的.
import React from 'react';
import Dashboard from './components/Dashboard';
class Dashboard extends React.Component {
componentDidMount() {
console.log('component mounted');
}
render() {
return <Dashboard />;
}
}
Run Code Online (Sandbox Code Playgroud) 我怎样才能将道具传递给javascript Vue组件.
这就是我通常的做法.
<child prop="value"></value>
Run Code Online (Sandbox Code Playgroud)
但我想这样做
var Child = Vue.extend({
...
});
Chid.passProps( {foo: 'bar'} ) // some thing like this?
Run Code Online (Sandbox Code Playgroud)
这可能在vue.js吗?
这是完整的代码:
var Child = Vue.extend({
props: ['foo'],
methods: {
printIt: function() {
console.log(this.foo)
}
},
template: '#example'
});
var vm = new Vue({
el: '#root',
data: {
foo: 'bar'
},
render: function(createElement) {
return createElement(Child); // pass down foo
}
});
Run Code Online (Sandbox Code Playgroud)
我正在使用Jquery数据表中的"打印"按钮,我正在尝试以编程方式更改"打印"按钮的打印页面标题.这是我第一次配置它.
var table = $('table').DataTable({
buttons: [
extend: 'print',
title: 'Monthly Report' // need to change this
]
});
Run Code Online (Sandbox Code Playgroud)
所以基本上我需要使用API 更改标题.请注意,此标题不是按钮上的文本.它是打印页面上的标题.(单击"打印"按钮时显示的页面)
我已经尝试使用像这样的API更改标题
table.api().buttons()[0].inst.c.buttons[0].title = 'Daily Reports';
Run Code Online (Sandbox Code Playgroud)
但它不起作用.任何帮助将非常感激.
我正在做这个本机反应项目,并且我正在使用这种方法来组织我的项目文件,但是我不知道如何在const中声明函数。
import React from 'react';
import { View, ListView, Text } from 'react-native';
const Category = (props) => {
const ds = ListView.DataSource({rowHasChanged : (r1, r2) => r1 !== r2});
// how to declare function here?
return (
<View>
<ListView
dataSource={ds}
renderRow={(rowData) => <Text>{rowData}</Text>}
renderSeparator={// how to put function reference here?}
/>
</View>
);
}
Run Code Online (Sandbox Code Playgroud) 我如何查询关系,仍然包括没有关系的模型?有两种型号
商店
产品
码
// Store
public function products() {
$this->belongsToMany('App\Store');
}
// Product
public function stores() {
$this->belongsToMany('App\Product');
}
Run Code Online (Sandbox Code Playgroud)
和一个用于连接它们的数据透视表product_store.有些商店没有任何产品.我如何查询所有产品,甚至是那些不属于任何商店的产品,例如:
Product::where('store.id', '=', 1)->get()
这就是我目前的做法.
Product::whereHas('stores', function($query) {
$query->where('id', '=', $store_id);
});
Run Code Online (Sandbox Code Playgroud)
但随着laravel文档提到这个
检索至少有一个商店的所有产品
ecmascript-6 ×2
laravel ×2
react-native ×2
browserify ×1
datatables ×1
eloquent ×1
gulp-watch ×1
less ×1
reactjs ×1
validation ×1
vue.js ×1